Tutorial: Run applications in Azure Kubernetes Service (AKS)

In this tutorial, part four of seven, a sample application is deployed into a Kubernetes cluster. Steps completed include:

  • Update Kubernetes manifest files
  • Run application in Kubernetes
  • Test the application

In subsequent tutorials, this application is scaled out and updated.

This tutorial assumes a basic understanding of Kubernetes concepts, for detailed information on Kubernetes see the Kubernetes documentation.

Before you begin

In previous tutorials, an application was packaged into a container image, this image was uploaded to Azure Container Registry, and a Kubernetes cluster was created.

To complete this tutorial, you need the pre-created azure-vote-all-in-one-redis.yaml Kubernetes manifest file. This file was downloaded with the application source code in a previous tutorial. Verify that you have cloned the repo, and that you have changed directories into the cloned repo.

If you have not done these steps, and would like to follow along, return to Tutorial 1 – Create container images.

Update manifest file

In this tutorial, Azure Container Registry (ACR) has been used to store a container image. Before running the application, the ACR login server name needs to be updated in the Kubernetes manifest file.

Get the ACR login server name with the az acr list command.

az acr list --resource-group myResourceGroup --query "[].{acrLoginServer:loginServer}" --output table

The manifest file has been pre-created with a login server name of microsoft. Open the file with any text editor. In this example, the file is opened with nano.

nano azure-vote-all-in-one-redis.yaml

Replace microsoft with the ACR login server name. This value is found on line 47 of the manifest file.

- name: azure-vote-front
  image: microsoft/azure-vote-front:v1

The above code then becomes.

- name: azure-vote-front
  image: <acrName>.azurecr.io/azure-vote-front:v1

Save and close the file.

Deploy application

Use the kubectl apply command to run the application. This command parses the manifest file and creates the defined Kubernetes objects.

kubectl apply -f azure-vote-all-in-one-redis.yaml


deployment "azure-vote-back" created
service "azure-vote-back" created
deployment "azure-vote-front" created
service "azure-vote-front" created

Test application

A Kubernetes service is created which exposes the application to the internet. This process can take a few minutes.

To monitor progress, use the kubectl get service command with the --watch argument.

kubectl get service azure-vote-front --watch

Initially the EXTERNAL-IP for the azure-vote-front service appears as pending.

azure-vote-front   <pending>     80:30676/TCP   7s

Once the EXTERNAL-IP address has changed from pending to an IP address, use CTRL-C to stop the kubectl watch process.

azure-vote-front   80:30676/TCP   2m

To see the application, browse to the external IP address.

Image of Kubernetes cluster on Azure

If the application did not load, it might be due to an authorization problem with your image registry.

Please follow these steps to allow access via a Kubernetes secret.

Next steps

In this tutorial, the Azure vote application was deployed to a Kubernetes cluster in AKS. Tasks completed include:

  • Download Kubernetes manifest files
  • Run the application in Kubernetes
  • Tested the application

Advance to the next tutorial to learn about scaling both a Kubernetes application and the underlying Kubernetes infrastructure.