Chat Zalo Chat Messenger Phone Number Đăng nhập
Tutorial: Update an application in Azure Kubernetes Service (AKS)

Tutorial: Update an application in Azure Kubernetes Service (AKS)

After you deploy an application to Kubernetes, you can upgrade it by specifying a new container image or a new image version. An upgrade is prepared so that only a portion of the deployment is upgraded at a time. This staged update allows the application to continue running during the upgrade. It also provides a rollback mechanism if a rollback fails.

This tutorial, part six of seven, updates the sample Azure Vote application. You will learn how to:

Before you begin

In previous tutorials, an application was packaged in a container image. This image was uploaded to Azure Container Registry and created an AKS cluster. The application was then deployed to the AKS cluster.

An application repository that includes the application’s source code and a previously created Docker Compose file used in this tutorial was also cloned. Verify that you have created a clone of the repository and that you have changed directories to the cloned directory. If you haven’t completed these steps and want to follow them, start with Tutorial 1 – Creating Container Images.

Update an


Let’s make a change to the sample application, and then upgrade the version already deployed to the AKS cluster. Make sure you are in the cloned azure-voting-app-redis directory. The source code for the sample application can be found inside the azure-vote directory. Open the config_file.cfg file with an editor

, such as vi: vi azure-vote/azure-vote/config_file.cfg

Change the values of VOTE1VALUE and VOTE2VALUE to different values, such as colors. The following example shows the updated values:

# UI Settings TITLE = ‘Azure Voting Application’ VOTE1VALUE = ‘Blue’ VOTE2VALUE = ‘Purple’ SHOWHOST = ‘false’

Save and close the file. In vi, use :wq.


the container


To re-create the front-end image and test the upgraded application, use docker-compose. The -build argument is used to instruct Docker Compose to re-image

the application: docker-compose up -build -d Test the application


To verify that the updated container image shows the changes, open a local web browser for http://localhost:8080


The updated values provided in the config_file.cfg file are displayed in the running application.

Tag and push

the image

Use the docker tag to tag the image. Replace <acrLoginServer> with the ACR login server name or public registry hostname and update the image version

to :v2 as follows: docker tag /azure-vote-front:v1 /azure-vote-front:v2

Now use docker push to upload the image to your registry. Replace <acrLoginServer> with the name of the ACR logon server.

docker push <acrLoginServer>/azure-vote-front:v2

Deploy the updated


To provide maximum uptime, multiple instances of the application pod must be run. Check the number of running front-end instances with the

kubectl get pods command: $ kubectl get pods NAME READY STATE RESTART AGE azure-vote-back-217588096-5w632 1/1 Running 0 10m azure-vote-front-233282510-b5pkz 1/1 Running 0 10m azure-vote-front-233282510-dhrtr 1/1 Running 0 10m azure-vote-front-233282510-pqbfk 1/1 Running 0 10m

If you don’t have multiple front-end pods, scale your deployment

of azure-vote-front as follows: kubectl scale -replicas=3 deployment/azure-vote-front

To update the application, use the kubectl set command. Update <acrLoginServer> with the login server or host name in the container registry and specify the v2 application version

: kubectl set image deployment azure-vote-front azure-vote-front=<acrLoginServer>/azure-vote-front:v2

To monitor the deployment, use the kubectl get pod command. As the updated application is deployed, the pods are terminated and recreated with the new container image.

kubectl get pods

The following example output shows pods terminating and new instances running as the deployment progresses:

$ kubectl get pods NAME READY STATE RESTART AGE azure-vote-back-2978095810-gq9g0 1/1 Running 0 5m azure-vote-front-1297194256-tpjlg 1/1 Running 0 1m azure-vote-front-1297194256-tptnx 1/1 Running 0 5m azure-vote-front-1297194256-zktw9 1/1 Ending 0 1m

Test the updated application

To view

The update application, first obtain the external IP address of the azure-vote-front service: kubectl get service azure-vote-front

Now open a web browser to the IP address of your service:

Next steps

In this tutorial, you updated an application and deployed it to the AKS cluster. Learned to:

Advance to the next tutorial to learn how to upgrade an AKS cluster to a new version of Kubernetes.

Contact US