Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right way to update deployments on Kubernetes

Tags:

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:

  • some times, it seems that a deployment is not triggered at all, and when I call rollout status, I get errors like this:

    $ kubectl rollout status deployments myapp
    Waiting for deployment spec update to be observed...
    error: timed out waiting for the condition
    
  • The rollout history command show the CHANGE-CAUSE as <none>, and I can't find a way of making it show anything useful in there.

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

like image 810
caarlos0 Avatar asked Mar 02 '17 17:03

caarlos0


People also ask

What is update strategy in Kubernetes?

The rolling update strategy is a gradual process that allows you to update your Kubernetes system with only a minor effect on performance and no downtime. Rolling update strategy flowchart. In this strategy, the Deployment selects a Pod with the old programming, deactivates it, and creates an updated Pod to replace it.

Which kubectl command can be used to do a deployment update?

You can use kubectl set to make changes to an object's image , resources (compute resource such as CPU and memory), or selector fields. The kubectl set image command updates the nginx image of the Deployment's Pods one at a time. You can use kubectl apply to update a resource by applying a new or updated configuration.


1 Answers

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).

like image 82
pagid Avatar answered Oct 04 '22 14:10

pagid