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?
Kubernetes will pull upon Pod creation if either (see updating-images doc):
:latest
imagePullPolicy: Always
is specifiedThis is great if you want to always pull. But what if you want to do it on demand: For example, if you want to use some-public-image:latest
but only want to pull a newer version manually when you ask for it. You can currently:
imagePullPolicy
to IfNotPresent
or Never
and pre-pull: Pull manually images on each cluster node so the latest is cached, then do a kubectl rolling-update
or similar to restart Pods (ugly easily broken hack!)imagePullPolicy
, do a kubectl apply
, restart the pod (e.g. kubectl rolling-update
), revert imagePullPolicy
, redo a kubectl apply
(ugly!)some-public-image:latest
to your private repository and do a kubectl rolling-update
(heavy!)No good solution for on-demand pull. If that changes, please comment; I'll update this answer.