Exploring Deployment Jobs strategies in Azure DevOps multi-stage YAML – Canary for AKS example
A Canary Deployment strategy for Azure Kubernetes Service (AKS) involves deploying updates to a small set of Kubernetes pods or services to validate changes before scaling them across the entire AKS environment.
This helps to ensure that updates don’t cause disruptions and issues can be resolved early.
Steps to Implement Canary Deployment for AKS in Azure DevOps
Deploy to Canary AKS Environment: Deploy updates to a small subset of AKS pods.
Monitor and Validate: Perform monitoring, testing, and validation on the Canary pods.
Approval and Full Deployment: After successful Canary testing, move to a full-scale deployment.
Example Multi-stage YAML for Canary Deployment to AKS
xxxxxxxxxx231stages2stageCanary3 jobs4jobDeployCanaryAKS5 steps6script7 kubectl apply -f ./canary-deployment.yaml8 kubectl rollout status deployment/myapp -n my-namespace9script10 kubectl get pods -n my-namespace11 kubectl logs $(kubectl get pods -n my-namespace | grep myapp-canary | awk '{print $1}') -n my-namespace12hooks13approval14 nameCanary Approval15 conditioneq(variables'Build.Status', 'Succeeded')16stageProduction17 dependsOnCanary18 jobs19jobDeployProductionAKS20 steps21script22 kubectl apply -f ./production-deployment.yaml23 kubectl rollout status deployment/myapp -n my-namespaceDetails of Canary Deployment for AKS
Canary Deployment: Deploy a small number of AKS pods using a dedicated Canary deployment configuration (
canary-deployment.yaml).Monitoring and Validation: Validate the health and stability of Canary pods using commands like
kubectl get podsandkubectl logs.Approval: Use an approval gate to ensure successful Canary validation before proceeding to full deployment.
Production Deployment: Deploy updates to the full AKS cluster using the production configuration (
production-deployment.yaml).
Detailed Steps
Deploy to Canary AKS:
Apply a dedicated Canary deployment configuration (
canary-deployment.yaml).Monitor the status of the deployment using
kubectl rollout status.
xxxxxxxxxx31script2kubectl apply -f ./canary-deployment.yaml3kubectl rollout status deployment/myapp -n my-namespaceValidate Canary Deployment: Get the list of pods and logs to ensure the Canary deployment is stable.
xxxxxxxxxx31script2kubectl get pods -n my-namespace3kubectl logs $(kubectl get pods -n my-namespace | grep myapp-canary | awk '{print $1}') -n my-namespaceApproval Hook: Implement an approval step after Canary validation to ensure only stable deployments move forward.
xxxxxxxxxx41hooks2approval3nameCanary Approval4conditioneq(variables'Build.Status', 'Succeeded')Production Deployment: Once Canary deployment is validated, proceed with deploying the production configuration.
xxxxxxxxxx31script2kubectl apply -f ./production-deployment.yaml3kubectl rollout status deployment/myapp -n my-namespace
Benefits of Canary Deployment for AKS
Reduced Risk: Smaller scale deployment to validate changes before scaling.
Early Detection: Quickly identify and fix issues without impacting the entire AKS cluster.
Progressive Rollout: Gradual expansion of updates, reducing downtime.
Monitoring and Validation: Enhanced visibility into deployment health through logging and status checks.






















Leave a Reply