caarlos0
caarlos0

Reputation: 20643

Right way to update deployments on Kubernetes

Currently, I'm updating the version of an image to be deployed using the set image command:

$ kubectl set image deployments myapp myapp=caarlos0/myapp:v2

And then I watch the changes with rollout status:

$ kubectl rollout status deployments myapp

The problems I found while doing it this way are:

So, am I doing something wrong (or not in the best way)? How can I improve this workflow?

Upvotes: 5

Views: 15914

Answers (2)

Girdhar Singh Rathore
Girdhar Singh Rathore

Reputation: 5615

Deployment is observed by the controlplane component Deployment controller, make sure kube-controller-manager is running. for example below controller-manager is not running so it will not rollout deployments.

enter image description here

once controller is up and running it will start rollout example below

enter image description here

Upvotes: 0

pagid
pagid

Reputation: 13877

You're doing the right thing. Within the Updating a deployment documentation you'll find this:

Note: a Deployment’s rollout is triggered if and only if the Deployment’s pod template (i.e. .spec.template) is changed, e.g. updating labels or container images of the template. Other updates, such as scaling the Deployment, will not trigger a rollout.

So running $ kubectl set image deployments/app <image> will only trigger a rollout if <image> is not already configured for your containers.

The change cause can be used to record the command which was used to trigger the rollout by appending the --record flag to your commands (see Checking rollout history).

Upvotes: 5

Related Questions