2 min read | by Jordi Prats
There are several strategies available for updating a deployment on Kubernetes, by default it will trigger a rolling update: It will deploy the new version before tearing down the old one so there's no downtime associated to it.
Let's see how we can see this process by applying an update to a deployment:
$ kubectl apply -f deployment.yaml
First it will start the new cotainer (notice the AGE column for each container):
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
pet2cattle-54b4f774b6-z6phh 1/1 Running 0 20m
pet2cattle-7855d874df-ppsfm 0/1 Running 0 3s
Once the new one is available, it will terminate the old one:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
pet2cattle-7855d874df-ppsfm 1/1 Running 0 17s
pet2cattle-54b4f774b6-z6phh 0/1 Terminating 0 20m
So at the end it will one be running the new one:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
pet2cattle-7855d874df-ppsfm 1/1 Running 0 26s
We can also check the status of the update using kubectl rollout status:
$ kubectl rollout status deploy pet2cattle
deployment "pet2cattle" successfully rolled out
If the deployment update haven't finished yet, this command will wait until the update have been completed:
$ kubectl rollout status deployment/pet2cattle
Waiting for deployment "pet2cattle" rollout to finish: 1 of 2 updated replicas are available...
deployment "pet2cattle" successfully rolled out
We even have a update history available:
$ kubectl rollout history deploy pet2cattle
deployment.apps/pet2cattle
REVISION CHANGE-CAUSE
21 <none>
22 <none>
23 <none>
24 <none>
26 <none>
28 <none>
29 <none>
30 <none>
32 <none>
33 <none>
34 <none>
Posted on 17/05/2021