Right way to update deployments on Kubernetes

3/2/2017

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?

-- caarlos0
kubernetes

1 Answer

3/2/2017

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

-- pagid
Source: StackOverflow