I have two containers defined in my yaml, both have the image pull poilicy as latest.
however when the pod is deployed, second container does not start, the pod yaml in kubernetes states that they both have the same image id.
spec:
containers:
- name: 1st
image: "x/abc:latest"
imagePullPolicy: "Never"
ports:
- containerPort: 8080
- containerPort: 5005
volumeMounts:
- name: config-volume
mountPath: /config
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
env:
- name: JVM_DEBUG
value: "True"
- name: second
image: "x/def:latest"
imagePullPolicy: "Never"
ports:
- containerPort: 9998
volumeMounts:
- name: config-volume
mountPath: /config
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
volumes:
- name: config-volume
configMap:
name: abc-RELEASE
any ideas?
I think you are mixing two concepts here: the image pull policy and the image tag.
The image pull policy tells kubernetes when you want it to try to download the container image. Since you are using a ImagePullPolicy
of Never
the image must already be present on the kubernetes node: kubernetes will not try to download the image. Besides Never
you can also choose Always
or IfNotPresent
. Unless you have a compelling reason to choose Never
, I'd choose IfNotPresent
whenever possible.
On the other hand, you have chosen the latest
image tag. That's the exactly tag that must be present on the kubernetes node when trying to create the container.
Furthermore, in your example yaml, you are using two differente images: x/abc
and x/def
. So both images must be present or the containers won't be able to be created by the kubernetes.