我有一个用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.ymldeployment.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时自动更新广告连播
发布评论