How to use rolling update to re-pull container image?

匿名 (未验证) 提交于 2019-12-03 00:57:01

问题:

I have a kubernetes RC/pod consisting of containers with images like: foobar/my-image:[branch]-latest where "branch" is the git branch ("master", etc).

What's the best way to use rolling-update to force the RC to re-pull the images to get the latest version? The brute force method is to simply delete the RC and re-create it, but that causes downtime for the service.

Is rolling update only possible if you specify an exact image tag, rather than something like "latest"?

回答1:

You should be able to use a rolling update specifying the same image name that you are currently using:

kubectl rolling-update <replication-controller-name> --image=foobar/myimage:[branch]-latest 

This will (behind the scenes) create a new replication controller that is a copy of your existing replication controller with the "new" image, and then stepwise resize each of the replication controllers until the old one has zero pods and the new one has the desired number of pods, finally deleting the old one and renaming the new one to use the old name.



回答2:

If you want the rolling update to re-pull your image, you must either use the :latest tag or specify a image pull policy of Always (see Updating Images in the Kubernetes docs).

In your case, you can't use the :latest tag since you want the most recent image on a particular branch, so using the pull policy is the way to go.

dns-frontend-pod.yaml is an example file showing how to use the image pull policy of Always.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!