Search⌘ K

Updating Deployments

Explore how to update Kubernetes Deployments by changing container images using kubectl set image. Understand how Deployments create new ReplicaSets to manage pods, allow zero downtime updates, and rollback old versions. Learn why updating through kubectl set image integrates better with CI/CD workflows and discover adding Services for internal communication.

Updating the db image

Let’s see what happens when we set a new image to the db Pod.

Shell
kubectl set image \
-f go-demo-2-db.yml \
db=mongo:3.4 \
--record

It’ll take a while until the new image is pulled.

Describing the deployment

Once it’s done, we can describe the Deployment by checking the events it created.

Shell
kubectl describe \
-f go-demo-2-db.yml

The last few lines of the output are as follows:

Shell
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 101s deployment-controller Scaled up replica set go-demo-2-db-76668544d4 to 1
Normal ScalingReplicaSet 11s deployment-controller Scaled up replica set go-demo-2-db-6b48fcbfcf to 1
Normal ScalingReplicaSet 10s deployment-controller Scaled down replica set go-demo-2-db-76668544d4 to 0

We can see that it creates a new ReplicaSet and scales the old ReplicaSet to 0. If, in your case, the last line did not appear, you’ll need to wait until the new version of the mongo image is pulled.

Instead of operating directly on the level of Pods, the Deployment creates a new ReplicaSet which subsequently produces Pods based on the new image. Once they ...