Kubernetes CKAD weekly challenge #4 Deployment Rollout Rollback

For information and tips read this.

Rules!

  1. be fast, avoid creating yaml manually from scratch
  2. use only kubernetes.io/docs for help.
  3. check my solution after you did yours. You might even have a better one ;)

Todays Task: Deployment, Rollouts and Rollbacks

  1. Create a deployment of 15 pods with image nginx:1.14.2 in namespace one.
  2. Confirm that all pods are running that image.
  3. Edit the deployment to change the image of all pods to nginx:1:15:10.
  4. Confirm that all pods are running image nginx:1.15.10.
  5. Edit the deployment to change image of all pods to nginx:1.15.666.
  6. Confirm that all pod are running image nginx:1.15.666 and have no errors. Show error if there is one.
  7. Woops! Something went crazy wrong here! Rollback the change, so all pods should run nginx:1.15.10 again.
  8. Confirm that all pods are running image nginx:1.15.10.

Solution:

kubectl create namespace one
kubectl create deployment nginx1 --image=nginx:1.14.2 --namespace=one
kubectl scale deployment nginx1 --replicas=15

2.

kubectl get pods -o yaml | grep 1.14.2
kubectl get pods -o yaml | grep 1.14.2 | wc -l
# should be 30 as the image is also listed in the status output

3.

kubectl edit deployments nginx1
# then manually edit the container image to nginx:1.15.10

4.

kubectl get pods -o yaml | grep 1.15.10 | wc -l

5.

kubectl edit deployments nginx1
# then manually edit the container image to nginx:1.15.666

6.

kubectl get pods -o yaml | grep 1.15.666 | wc -l
# something wrong
kubectl get pods
kubectl log nginx1-64cfc7f765-24kwb

Oups! Let’s roll back.

7.

kubectl rollout history deployment nginx1 # show available
kubectl rollout undo deployment nginx1

8.

kubectl get pods -o yaml | grep 1.14.2 | wc -l

End

We did it ;)

OVERVIEW