0
0
Jenkinsdevops~10 mins

Canary deployment pattern in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a Jenkins pipeline stage for canary deployment.

Jenkins
stage('Canary Deployment') {
  steps {
    script {
      sh 'kubectl apply -f [1]'
    }
  }
}
Drag options to blanks, or click blank then click option'
Atest-deployment.yaml
Bproduction-deployment.yaml
Crollback.yaml
Dcanary-deployment.yaml
Attempts:
3 left
💡 Hint
Common Mistakes
Using the production deployment file instead of canary.
2fill in blank
medium

Complete the code to set the percentage of traffic to route to the canary version.

Jenkins
environment {
  CANARY_PERCENT = '[1]'
}
Drag options to blanks, or click blank then click option'
A10%
B50%
C100%
D0%
Attempts:
3 left
💡 Hint
Common Mistakes
Setting 100% traffic immediately, which is not a canary.
3fill in blank
hard

Fix the error in the command to update the service to route traffic to the canary deployment.

Jenkins
sh 'kubectl patch svc my-service -p "[1]"'
Drag options to blanks, or click blank then click option'
A{"spec":{"selector":{"version":"test"}}}
B{"spec":{"selector":{"version":"prod"}}}
C{"spec":{"selector":{"version":"canary"}}}
D{"spec":{"selector":{"version":"old"}}}
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prod' or other labels that do not route to canary.
4fill in blank
hard

Fill both blanks to define a Jenkins pipeline step that waits for the canary deployment to be ready and then verifies it.

Jenkins
stage('Verify Canary') {
  steps {
    sh 'kubectl rollout status deployment/[1]'
    sh 'curl -f http://[2]/health || exit 1'
  }
}
Drag options to blanks, or click blank then click option'
Acanary-app
Bprod-app
Ccanary-service
Dprod-service
Attempts:
3 left
💡 Hint
Common Mistakes
Checking production deployment or service instead of canary.
5fill in blank
hard

Fill all three blanks to define a Jenkins pipeline snippet that promotes the canary to production by updating the deployment and service selectors.

Jenkins
stage('Promote Canary') {
  steps {
    sh 'kubectl patch deployment [1] -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"version\":\"[2]\"}}}}}"'
    sh 'kubectl patch svc [3] -p "{\"spec\":{\"selector\":{\"version\":\"[2]\"}}}"'
  }
}
Drag options to blanks, or click blank then click option'
Aprod-app
Bcanary
Cprod-service
Dcanary-app
Attempts:
3 left
💡 Hint
Common Mistakes
Using canary deployment name instead of production for deployment patch.