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?
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With