I have the following replication controller in Kubernetes on GKE:
apiVersion: v1
kind: ReplicationController
metadata:
name: myapp
labels:
app: myapp
spec:
replicas: 2
selector:
app: myapp
deployment: initial
template:
metadata:
labels:
app: myapp
deployment: initial
spec:
containers:
- name: myapp
image: myregistry.com/myapp:5c3dda6b
ports:
- containerPort: 80
imagePullPolicy: Always
imagePullSecrets:
- name: myregistry.com-registry-key
Now, if I say
kubectl rolling-update myapp --image=us.gcr.io/project-107012/myapp:5c3dda6b
the rolling update is performed, but no re-pull. Why?
One has to group imagePullPolicy
inside the container data instead of inside the spec data. However, I filed an issue about this because I find it odd. Besides, there is no error message.
So, this spec snippet works:
spec:
containers:
- name: myapp
image: myregistry.com/myapp:5c3dda6b
ports:
- containerPort: 80
imagePullPolicy: Always
imagePullSecrets:
- name: myregistry.com-registry-key
Please be aware, that if the image is already cached on the local node, it will not be re-pulled (you will have to change the remote image). This applies even when the local image is actually different, e.g. corrupted by misguided attempts to free some space manually, because image checksums are not re-computed.