Updating application, scaling AKS cluster
In continuation of my AKS series, this part 3 contains how to update and scale application on Azure Kubernetes Service. I hope that you are also following with my blog series and completed below steps:
- Setting up local environment for Docker, and create a Docker image locally) – Part 1
- Provisioning and deploying ACR to secure docker image, deploy AKS cluster to host image – Part 2
If not please complete that and you can continue progressing further.
Now let’s get started, in this article we are going to see how we can update our existing application and publish it back to AKS cluster and how can we scale our AKS cluster in the time of peak load.
First we are going to start with update application with content and then will continue with application scaling.
Update application
- To update the application we are going to do small change in HTML content and release the application. Go to the application folder-> WebContent and open listEmployee.jsp file. Modify the body h3 tag and update with some other text like “Employee Information of My Organization” and save the file
- Now to update that changes, go to command prompt and rebuild the application by running the following command:
mvn clean install
Note: I’m assuming that you are performing this lab in sequence so that you are continuing with your previous command prompt session. If not you have to start with cmd and run the above command
- Once the application build is completed, to create docker image again use below command:
docker build -t empapp
- After image getting build, create a new tag with ACR loginserver name and v2 has version info
docker tag empapp aksdemoacr.azurecr.io/empapp:v2
- Now you will have image ready with updated version with new V2 tag, push this image to ACR
docker push aksdemoacr.azurecr.io/empapp:v2
If you see any authorization error, run below command to log in with your ACR creds:
az acr login –name aksdemoacr
- After pushing your image into ACR, next step is to update the container in AKS cluster:
kubectl set image deployment azure-emp-java
azure-empjava=aksdemoacr.azurecr.io/empapp:v2
Go back to your AKS page and view application in browser OR if you are already running application you can refresh your page to see update.
Scale AKS Cluster
In this section we are going to see how can we scale AKS cluster and manage it. To scale your cluster you need to know how many nodes you are running currently and how many more you wants to add in your cluster.
- To do that run the following commands to get the count of nodes in your cluster
kubectl get nodes
- Once you get the number of nodes, you can scale your cluster by running below command and increase capacity of your AKS cluster.
az aks scale --resource-group=aksdemorgp --name=myAKSCluster --node-count 3
- You can check in kubernetest dashboard and verify that you have got updated with 3 nodes
- You can see that the node count has been increased from 1 to 3, but we have only one instance of the application(pod). To check that, execute the following command:
kubectl get pods
- This will limits the high availability of your application, so we are going to replicate number of pods according to cluster:
kubectl scale --replicas=3 deployment/azure-emp-java
- Verify the same by running again the following command:
kubectl get pods
- Go to dashboard and click on Pods to verify the same in kubernetes dashboard
So you can how easily we have updated our application and configure scale to number of nodes and pods into AKS cluster.
Continue reading my blog series of “Simplifying Container Orchestration with Azure Kubernetes Service (AKS)”