The issue might occur when k8s is trying to pull image other than using local images, but couldn’t pull the image correctly.
This is due to when the Image of the container doesn’t have a specific tag, imagePullPolicy
might be set to Always
.
See Official Docs: Default image pull policy
Omit the imagePullPolicy and the tag for the image to use; Kubernetes will set the policy to Always when you submit the Pod. ^Ref
For instance, the status of middleware-deploy went ImagePullBackOff
# kubectl get pods
NAME READY STATUS RESTARTS AGE
middleware-deploy-646f6598c-mq88b 0/1 ImagePullBackOff 0 89s
The reason that I would say this issue would be a potential one is, when we
… first create a Deployment, StatefulSet, Pod, or other objects that include a Pod template, then by default the pull policy of all containers in that pod will be set to IfNotPresent if it is not explicitly specified. ^Ref
Therefore, to avoid the conflicts of k8s default behavior, I recommend to specify the image tag and set imagePullPolicy
to IfNotPresent
explicitly.
To modify image
and imagePullPolicy
on the fly:
kubectl edit deploy/<deploy-name>
If you only want to change the image, there is a more elegant way:
kubectl set image deploy/<deploy-name> <container-name>=<image:tag>
And don’t forget to add an annotation, it’s a good habit:
kubectl annotate deploy/<deploy-name> kubernetes.io/change-cause="modify image or set imagePullPolicy to IfNotPresent"