0% found this document useful (0 votes)
19 views4 pages

Exercise 7.3: Rolling Updates and Rollbacks: Nginx Versions

Uploaded by

tektitemo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views4 pages

Exercise 7.3: Rolling Updates and Rollbacks: Nginx Versions

Uploaded by

tektitemo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

7.6.

LABS 1

Exercise 7.3: Rolling Updates and Rollbacks


One of the advantages of micro-services is the ability to replace and upgrade a container while continuing to respond to client
requests. We will use the default OnDelete setting that upgrades a container when the predecessor is deleted, then the use
the RollingUpdate feature as well.

nginx versions
The nginx software updates on a distinct timeline from Kubernetes. If the lab shows an older version please use the
current default, and then a newer version. Versions can be seen with this command: sudo docker image ls nginx

1. Begin by viewing the current updateStrategy setting for the DaemonSet created in the previous section.
student@lfs458-node-1a0a:~$ kubectl get ds ds-one -o yaml \
| grep -A 1 Strategy

updateStrategy:
type: OnDelete

2. Update the DaemonSet to use a newer version of the nginx server. This time use the set command instead of edit. Set
the version to be 1.12.1-alpine.
student@lfs458-node-1a0a:~$ kubectl set image ds ds-one nginx=nginx:1.12.1-alpine
daemonset.extensions/ds-one image updated

3. Verify that the Image: parameter for the Pod checked in the previous section is unchanged.
student@lfs458-node-1a0a:~$ kubectl describe po ds-one-b1dcv |grep Image:
Image: nginx:1.11.1

4. Delete the Pod. Wait until the replacement Pod is running and check the version.
student@lfs458-node-1a0a:~$ kubectl delete po ds-one-b1dcv
pod "ds-one-b1dcv" deleted

student@lfs458-node-1a0a:~$ kubectl get po


NAME READY STATUS RESTARTS AGE
ds-one-xc86w 1/1 Running 0 19s
ds-one-z31r4 1/1 Running 0 4m8s

student@lfs458-node-1a0a:~$ kubectl describe po ds-one-xc86w |grep Image:


Image: nginx:1.12.1-alpine

5. View the image running on the older Pod. It should still show version 1.11.1.
student@lfs458-node-1a0a:~$ kubectl describe po ds-one-z31r4 |grep Image:
Image: nginx:1.11.1

6. View the history of changes for the DaemonSet. You should see two revisions listed. The number of revisions kept is set
in the DaemonSet with v.1.12.1 the history kept has increased to ten from two, by default.

student@lfs458-node-1a0a:~$ kubectl rollout history ds ds-one

LFS258: V 2019-08-12 © Copyright the Linux Foundation 2019. All rights reserved.
2 CHAPTER 7. MANAGING STATE WITH DEPLOYMENTS

daemonsets "ds-one"
REVISION CHANGE-CAUSE
1 <none>
2 <none>

7. View the settings for the various versions of the DaemonSet. The Image: line should be the only difference between the
two outputs.

student@lfs458-node-1a0a:~$ kubectl rollout history ds ds-one --revision=1


daemonsets "ds-one" with revision #1
Pod Template:
Labels: system=DaemonSetOne
Containers:
nginx:
Image: nginx:1.11.1
Port: 80/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>

student@lfs458-node-1a0a:~$ kubectl rollout history ds ds-one --revision=2


....
Image: nginx:1.12.1-alpine
.....

8. Use kubectl rollout undo to change the DaemonSet back to an earlier version. As we are still using the OnDelete
strategy there should be no change to the Pods.

student@lfs458-node-1a0a:~$ kubectl rollout undo ds ds-one --to-revision=1


daemonset.extensions/ds-one rolled back

student@lfs458-node-1a0a:~$ kubectl describe po ds-one-xc86w |grep Image:


Image: nginx:1.12.1-alpine

9. Delete the Pod, wait for the replacement to spawn then check the image version again.

student@lfs458-node-1a0a:~$ kubectl delete po ds-one-xc86w


pod "ds-one-xc86w" deleted

student@lfs458-node-1a0a:~$ kubectl get po


NAME READY STATUS RESTARTS AGE
ds-one-qc72k 1/1 Running 0 10s
ds-one-xc86w 0/1 Terminating 0 12m
ds-one-z31r4 1/1 Running 0 28m

student@lfs458-node-1a0a:~$ kubectl describe po ds-one-qc72k |grep Image:


Image: nginx:1.11.1

10. View the details of the DaemonSet. The Image should be v1.11.1 in the output.

student@lfs458-node-1a0a:~$ kubectl describe ds |grep Image:


Image: nginx:1.11.1

11. View the current configuration for the DaemonSet in YAML output. Look for the update strategy near the end of the
output.

LFS258: V 2019-08-12 © Copyright the Linux Foundation 2019. All rights reserved.
7.6. LABS 3

student@lfs458-node-1a0a:~$ kubectl get ds ds-one -o yaml

apiVersion: extensions/v1beta1
kind: DaemonSet
.....
terminationGracePeriodSeconds: 30
templateGeneration: 3
updateStrategy:
type: OnDelete
status:
currentNumberScheduled: 2
.....

12. Create a new DaemonSet, this time setting the update policy to RollingUpdate. Begin by generating a new config file.

student@lfs458-node-1a0a:~$ kubectl get ds ds-one -o yaml --export > ds2.yaml

13. Edit the file. Change the name, around line eight and the update strategy around line 38.
student@lfs458-node-1a0a:~$ vim ds2.yaml

....
name: ds-two
....
type: RollingUpdate

14. Create the new DaemonSet and verify the nginx version in the new pods.

student@lfs458-node-1a0a:~$ kubectl create -f ds2.yaml


daemonset.extensions/ds-two created

student@lfs458-node-1a0a:~$ kubectl get po


NAME READY STATUS RESTARTS AGE
ds-one-qc72k 1/1 Running 0 28m
ds-one-z31r4 1/1 Running 0 57m
ds-two-10khc 1/1 Running 0 5m
ds-two-kzp9g 1/1 Running 0 5m

student@lfs458-node-1a0a:~$ kubectl describe po ds-two-10khc |grep Image:


Image: nginx:1.11.1

15. Edit the configuration file and set the image to a newer version such as 1.12.1-alpine.

student@lfs458-node-1a0a:~$ kubectl edit ds ds-two

....
- image: nginx:1.12.1-alpine
.....

16. View the age of the DaemonSets. It should be around ten minutes old, depending on how fast you type.

student@lfs458-node-1a0a:~$ kubectl get ds ds-two


NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE-SELECTOR AGE
ds-two 2 2 2 2 2 <none> 10m

17. Now view the age of the Pods. Two should be much younger than the DaemonSet. They are also a few seconds apart
due to the nature of the rolling update where one then the other pod was terminated and recreated.

student@lfs458-node-1a0a:~$ kubectl get po

LFS258: V 2019-08-12 © Copyright the Linux Foundation 2019. All rights reserved.
4 CHAPTER 7. MANAGING STATE WITH DEPLOYMENTS

NAME READY STATUS RESTARTS AGE


ds-one-qc72k 1/1 Running 0 36m
ds-one-z31r4 1/1 Running 0 1h
ds-two-2p8vz 1/1 Running 0 34s
ds-two-8lx7k 1/1 Running 0 32s

18. Verify the Pods are using the new version of the software.

student@lfs458-node-1a0a:~$ kubectl describe po ds-two-8lx7k |grep Image:


Image: nginx:1.12.1-alpine

19. View the rollout status and the history of the DaemonSets.

student@lfs458-node-1a0a:~$ kubectl rollout status ds ds-two


daemon set "ds-two" successfully rolled out

student@lfs458-node-1a0a:~$ kubectl rollout history ds ds-two


daemonsets "ds-two"
REVISION CHANGE-CAUSE
1 <none>
2 <none>

20. View the changes in the update they should look the same as the previous history, but did not require the Pods to be
deleted for the update to take place.

student@lfs458-node-1a0a:~$ kubectl rollout history ds ds-two --revision=2


...
Image: nginx:1.12.1-alpine

21. Clean up the system by removing one of the DaemonSets. We will leave the other running.

student@lfs458-node-1a0a:~$ kubectl delete ds ds-two


daemonset.extensions "ds-two" deleted

LFS258: V 2019-08-12 © Copyright the Linux Foundation 2019. All rights reserved.

You might also like