Kubernates pods with :latest Image issue
If the image tag is the same in both
apply
andset image
then only theapply
action re-deploy the Deployment (in which case you do not need theset image
command). If they refer to different image tags then yes, the deployment will be run twice.If you use
latest
tag, applying a manifest that use thelatest
tag with no modification WILL NOT re-deploy the Deployment. You need to introduce a modification to the manifest file in order to force Kubernetes to re-deploy. Like for my case, I usedate
command to generate aTIMESTAMP
variable that is passed as in theenv
spec of the pod container which my container does not use in any way, just to force a re-deploy of the Deployment. Or you can also usekubectl rollout restart deployment/name
if you are using Kubernetes 1.15 or later.Other than wasted bandwidth or if you are being charged by how many times you pull a docker image (poor you), there is no harm with additional image pull just to be sure you are using the latest image version. Even if you use a specific image tag with version numbers like
1.10.112-rc5
, they will be case where you or your fellow developers forget to update the version number when pushing a modified image version. IMHO,imagePullPolicy=always
should be the default rather than explicitly required.