Re-pulling image in kubernetes

0 votes

I have set up a kubernetes cluster on GKE.

My replication controller YAML:

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

But if I try and do an rolling update:

kubectl rolling-update myapp --image=us.gcr.io/project-107012/myapp:5c3dda6b

the rolling update is successful but there's no re-pull of the image

Jan 9 in Kubernetes by shubham
• 6,870 points
55 views

1 answer to this question.

0 votes

There are only two scenarios when kubernetes will pull an image for pod creation(see updating-images doc):

  • Using images tagged :latest
  • imagePullPolicy: Always is specified

This 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:

This works if you always want to pull the image. You can also pull on demand if you want, eg. you need to use exampleImage:latest only when a new version is put up. So you can:

  • Set 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!)
  • Temporarily change imagePullPolicy, do a kubectl apply, restart the pod (e.g. kubectl rolling-update), revert imagePullPolicy, redo a kubectl apply (ugly!)
  • Pull and push some-public-image:latest to your private repository and do a kubectl rolling-update (heavy!)

answered Jan 9 by ajs3033
• 7,240 points

Related Questions In Kubernetes

0 votes
3 answers

Retry pull image in a kubernetes pod

If the Pod is part of a ...READ MORE

answered Aug 29, 2018 in Kubernetes by Hannah
• 14,080 points
760 views
+1 vote
1 answer

--image-pull-policy not working in kubernetes

Kubernetes does not automatically update the pods ...READ MORE

answered Dec 6, 2018 in Kubernetes by DareDev
• 6,810 points
577 views
0 votes
1 answer

Building an image in kubernetes using Kompose

Kompose supports both building and pushing Docker ...READ MORE

answered 3 days ago in Kubernetes by Sirajul
• 5,960 points
7 views
+5 votes
2 answers

Redirecting host to service path in kubernetes

What you are trying to do is ...READ MORE

answered Mar 27, 2018 in Kubernetes by DragonLord999
• 8,380 points
70 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
1,143 views
+3 votes
1 answer
0 votes
1 answer

How to use gravitational teleport in a container/kubernetes environment?

You can use teleport to augment kubernetes ...READ MORE

answered Jun 28, 2018 in Kubernetes by ajs3033
• 7,240 points
256 views
0 votes
2 answers