Exercise 7.3: Rolling Updates and Rollbacks: Nginx Versions
Exercise 7.3: Rolling Updates and Rollbacks: Nginx Versions
LABS 1
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
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.
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.
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.
9. Delete the Pod, wait for the replacement to spawn then check the image version again.
10. View the details of the DaemonSet. The Image should be v1.11.1 in the output.
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
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.
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.
15. Edit the configuration file and set the image to a newer version such as 1.12.1-alpine.
....
- 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.
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.
LFS258: V 2019-08-12 © Copyright the Linux Foundation 2019. All rights reserved.
4 CHAPTER 7. MANAGING STATE WITH DEPLOYMENTS
18. Verify the Pods are using the new version of the software.
19. View the rollout status and the history of the DaemonSets.
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.
21. Clean up the system by removing one of the DaemonSets. We will leave the other running.
LFS258: V 2019-08-12 © Copyright the Linux Foundation 2019. All rights reserved.