when updating deployment with a none-exist image, Kubernetes first will start terminating the existing pod and will end up with a broken deployment. is it possible to tell kubectl to validate/pull the image before terminating existing pod?
While I have not tested this I think in theory this should work:
You can use the admission controller AlwaysPullImages and a deployment strategy where at least one pod is up. The admission controller ensures that images are Always pulled before the pod is started.
To enable this admission controller you will have to enable flag at Kubernetes API server like from this link:
kube-apiserver --enable-admission-plugins=AlwaysPullImages,LimitRangerImplementing Liveness / Readiness will ensure that old pod gets terminated only if the new pod is healthy.
I had to change the strategy.rollingUpdate.maxUnavailable to 0
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdateI think that the default of strategy.rollingUpdate.maxUnavailable is 1
Thanks Michael Hausenblas