Triggering a rollout after pushing a new image

8/31/2017

I followed the tutorial here https://cloud.google.com/python/django/container-engine#initialize_your_cloud_sql_instance

I have successfully deployed my service but the tutorial stops before getting to updating the deployment.

What I've tried to do is this. But it doesn't seem to actually update the pods or deploy the code.

docker build -t gcr.io/<my-app>/polls .
gcloud docker -- push gcr.io/<my-app>/polls
kubectl apply -f polls.yaml
-- kevswanberg
google-kubernetes-engine
kubernetes

1 Answer

8/31/2017

See the note and example in the docs about updating a Deployment:

Note: A Deployment’s rollout is triggered if and only if the Deployment’s pod template (that is, .spec.template) is changed, for example if the labels or container images of the template are updated.

Even though you have pushed a new image version the template itself is unchanged; the template still refers to the image as gcr.io/<my-app>/polls or gcr.io/<my-app>/polls:latest. And although the meaning of that is changed the string itself is unchanged.

To trigger an update push a new tag, say gcr.io/<my-app>/polls:v2, edit the yaml file and execute kubectl apply -f polls.yaml.

You can also use kubectl set image to trigger an update without changing the Deployment yaml file (demo); the same rule applies, the string identifying the image must change from what is deployed at the moment.

If you don't want create image tags you can also use the sha256sum of your new image (the value is displayed when you push the image); works in the yaml file too:

kubectl set image deploy/mydeployment mycontainer=gcr.io/<my-app>/polls@sha256:2aac5e7514fbc77125bd315abe9e7b0257db05fe498af01a58e239ebaccf82a8

The discussion about this inconvenience is in issue #33664 if you are interested in other ideas.

-- Janos Lenart
Source: StackOverflow