Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto update pod on every image push to GCR

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?

like image 545
shoegazerpt Avatar asked Dec 04 '25 17:12

shoegazerpt


2 Answers

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

like image 190
Radek 'Goblin' Pieczonka Avatar answered Dec 07 '25 16:12

Radek 'Goblin' Pieczonka


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

like image 42
Steven Avatar answered Dec 07 '25 18:12

Steven



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!