Comprehensive guide on the Deployment Jobs strategies in Azure DevOps multi-stage YAML
In Azure DevOps Multi-stage YAML pipelines, various deployment strategies can be employed to optimize the deployment process. Below is an exploration of RunOnce, Rolling, and Canary deployment strategies, along with a specific example of Canary Deployment for AKS.
1. RunOnce Deployment Strategy
RunOnce:
This strategy is useful for tasks that should be executed only once, such as initialization, configuration setup, or infrastructure deployment.
xxxxxxxxxx71stages2stageSetup3 jobs4jobRunOnceJob5 runsOnself-hosted6 steps7scriptecho "Setting up initial configuration..."2. Rolling Deployment Strategy
Rolling:
Deploy updates incrementally to minimize risk by moving from lower environments to higher environments, ensuring stability at each stage.
xxxxxxxxxx181stages2stageDev3 jobs4jobDeployDev5 steps6scriptecho "Deploying to Development environment..."7stageStaging8 dependsOnDev9 jobs10jobDeployStaging11 steps12scriptecho "Deploying to Staging environment..."13stageProduction14 dependsOnStaging15 jobs16jobDeployProduction17 steps18scriptecho "Deploying to Production environment..."3. Canary Deployment Strategy
Canary:
Gradually deploy updates to a small, controlled subset of users or resources to validate changes before full rollout.
xxxxxxxxxx201stages2stageCanary3 jobs4jobDeployCanary5 steps6script7 kubectl apply -f ./canary-deployment.yaml8 kubectl rollout status deployment/myapp -n my-namespace9hooks10approval11 nameCanary Approval12 conditioneq(variables'Build.Status', 'Succeeded')13stageProduction14 dependsOnCanary15 jobs16jobDeployProduction17 steps18script19 kubectl apply -f ./production-deployment.yaml20 kubectl rollout status deployment/myapp -n my-namespace4. Canary Deployment for AKS
Canary for AKS:
Similar to Canary deployment, but specifically for AKS environments, where only a subset of Kubernetes pods are updated and monitored.
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-namespaceSummary of Strategies
RunOnce: Ideal for setting up configurations, infrastructure, or one-time jobs.
Rolling: Deploying updates incrementally, ensuring stability at each step.
Canary: Deploying a small portion of resources or users to validate changes before full deployment.
Canary for AKS: A specialized version of Canary for Kubernetes, validating and monitoring updates in AKS environments.






















Leave a Reply