Performing rolling updates and rollbacks
Rolling updates provide a way to update a Deployment to a newer version more effectively and efficiently. This way, you can update Kubernetes objects such as replicas and pods gradually with nearly zero downtime. In a nutshell, you may consider either using the kubectl set image
command or going straight to updating a YAML manifest file. In this section, we will introduce kubectl set image
, as it is very effective and handy to use in your actual CKA exam.
Rolling updates with kubectl
From here, we’ll go through the steps of rolling updates with kubectl
:
- You can spin up a new Deployment,
kubeserve
, using the following command:kubectl create deployment kubeserve --image=nginx:latest
- You can use
kubectl
to update the container image as follows:kubectl set image deployment/kubeserve nginx=nginx:1.18.0 --record
Important note
--record flag
records information about the updates so that it can be rolled back later...