Auto update pod on every image push to GCR

9/28/2016

I have a docker image pushed to Container Registry with docker push gcr.io/go-demo/servertime and a pod created with kubectl run servertime --image=gcr.io/go-demo-144214/servertime --port=8080.

How can I enable automatic update of the pod everytime I push a new version of the image?

-- shoegazerpt
google-container-registry
google-kubernetes-engine
kubernetes

3 Answers

9/28/2016

I'm on the Spinnaker team.

Might be a bit heavy, but without knowing your other areas of consideration, Spinnaker is a CD platform from which you can trigger k8s deployments from registry updates.

Here's a codelab to get you a started.

If you'd rather shortcut the setup process, you can get a starter Spinnaker instance with k8s and GCR integration pre-setup via the Cloud Launcher.

You can find further support on our slack channel (I'm @stevenkim).

-- Steven
Source: StackOverflow

9/28/2016

I would suggest switching to some kind of CI to manage the process, and instead of triggering on docker push triggering the process on pushing the commit to git repository. Also if you switch to using a higher level kubernetes construct such as deployment, you will be able to run a rolling-update of your pods to your new image version. Our process is roughly as follows :

git commit #triggers CI build
docker build yourimage:gitsha1
docker push yourimage:gitsha1
sed -i 's/{{TAG}}/gitsha1/g' deployment.yml
kubectl apply -f deployment.yml 

Where deployment.yml is a template for our deployment that will be updated to new tag version.

If you do it manually, it might be easier to simply update image in an existing deployment by running kubectl set image deployment/yourdeployment <containernameinpod>=yourimage:gitsha1

-- Radek 'Goblin' Pieczonka
Source: StackOverflow

9/30/2016

It would need some glue, but you could use Docker Hub, which lets you define a webhook for each repository when a new image is pushed or a new tag created.

This would mean you'd have to build your own web API server to handle the incoming notifications and use them to update the pod. And you'd have to use Docker Hub, not Google Container Repository, which doesn't allow web hooks.

So, probably too many changes for the problem you're trying to solve.

-- Evan Prodromou
Source: StackOverflow