Azure Kubernetes Service

Working with AKS

Upgrading your application

In this guide, you’ll learn how to upgrade your running application from version v1 to v2 using Azure Container Registry (ACR) and Azure Kubernetes Service (AKS). We’ll cover exposing the app, performing a rolling update, verifying the new version, and—if needed—rolling back to a previous revision.


1. Expose Your Deployment via a LoadBalancer

First, ensure your v1 image is deployed and reachable from the Internet:

PS C:\Users\msadmin> kubectl expose deployment kodekloudapp \
  --type=LoadBalancer --target-port=80 --port=80
service/kodekloudapp exposed

Check the service status:

Service NameTypeCluster IPExternal IPPortsAge
kodekloudappLoadBalancer10.0.112.11320.205.144.23780:30344/TCP2m
kubernetesClusterIP10.0.0.1<none>443/TCP2d

Note

If the EXTERNAL-IP remains <pending>, wait a minute or check your Azure networking configuration.


2. Perform a Rolling Update to v2

To point the existing deployment at your v2 image in ACR, use:

PS C:\Users\msadmin> kubectl set image deployment/kodekloudapp \
  kodekloudapp=crkodekloud.azurecr.io/kodekloudapp:v2
deployment.apps/kodekloudapp image updated

Kubernetes will perform a rolling update—terminating old pods and creating new ones—without downtime for your users.


3. Verify the Updated Version

Once the update completes, refresh your application’s public IP in the browser. You should see the v2 message.

To confirm the deployment is using the new image:

PS C:\Users\msadmin> kubectl describe deployment kodekloudapp

Under Pod Template → Containers, look for:

Image: crkodekloud.azurecr.io/kodekloudapp:v2


4. Rolling Back to a Previous Revision

Kubernetes retains a history of deployment revisions by default. If you encounter issues in v2, you can quickly revert to v1.

View the rollout history:

PS C:\Users\msadmin> kubectl rollout history deployment/kodekloudapp
RevisionChange Cause
1<none>
2<none>

Warning

Rolling back in production can affect end users. Consider testing rollbacks in a staging environment first.

To undo to the previous revision:

PS C:\Users\msadmin> kubectl rollout undo deployment/kodekloudapp
deployment.apps/kodekloudapp rolled back

After the rollback finishes, refresh your app endpoint to confirm v1 is active again.


Next Steps

You’ve successfully managed upgrades and rollbacks in AKS. Next, explore Azure Kubernetes Fleet Management to coordinate multiple clusters and streamline governance.


Watch Video

Watch video content

Previous
Pushing Image to ACR