每次将图片推送到GCR时自动更新广告连播 [英] Auto update pod on every image push to GCR

查看:108
本文介绍了每次将图片推送到GCR时自动更新广告连播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用docker push gcr.io/go-demo/servertime推送到Container Registry的docker映像,和一个用kubectl run servertime --image=gcr.io/go-demo-144214/servertime --port=8080创建的pod.

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.

每当我推送图像的新版本时,如何启用pod的自动更新?

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

推荐答案

我建议切换到某种CI来管理进程,而不是在docker push上触发,而在将提交推送到git仓库时触发该进程.同样,如果您切换到使用更高级别的kubernetes构造(例如deployment),则可以将Pod滚动更新到新的图像版本.我们的过程大致如下:

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 

deployment.yml是用于我们的部署的模板,该模板将更新为新的标记版本.

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

如果您手动执行此操作,则可以通过运行kubectl set image deployment/yourdeployment <containernameinpod>=yourimage:gitsha1

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

这篇关于每次将图片推送到GCR时自动更新广告连播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆