Home > Software engineering >  Kubernetes keeps re-pulling images
Kubernetes keeps re-pulling images

Time:02-04

Using microk8s installation. An image is tagged, so should use IfNotPresent policy.

apiVersion: apps/v1
  2 kind: Deployment
  3 metadata:
  4   name: lh-graphql
  5   labels:
  6     app: lh-graphql 
  7 spec:
  8   selector:
  9     matchLabels:
 10       app: lh-graphql
 11   strategy:
 12     type: Recreate
 13   template:
 14     metadata:
 15       labels:
 16         app: lh-graphql
 17     spec:
 18       containers:
 19       - image: hasura/graphql-engine:v2.13.2.cli-migrations-v3 
 20         name: lh-graphql 
 21         ports:
 22         - containerPort: 8080
 23           name: lh-graphql        
 24         env:
 25         - name: HASURA_GRAPHQL_DATABASE_URL  
 26           value: postgresql://postgres:postgres@$(ORCH_POSTGRES_IP):5432/lh

Image is already pulled to docker:

light@siddhalok:~$ docker image ls
REPOSITORY                                                   TAG                         IMAGE ID       CREATED        SIZE
postgres                                                     12                          3d6880d04326   2 weeks ago    373MB
hasura/graphql-engine                                        v2.13.2.cli-migrations-v3   4cd490369623   2 months ago   570MB

However, it keeps pulling after a deployment is deleted and created again.

Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  112s  default-scheduler  Successfully assigned default/lh-graphql-6db75544cf-j65wp to siddhalok
  Normal  Pulling    112s  kubelet            Pulling image "hasura/graphql-engine:v2.13.2.cli-migrations-v3"

UPD:

The same happens when creating from command line:

microk8s kubectl run det2 --image=registry.dev.mpksoft.ru/lighthouse/lh-detector/lh-detector:current --image-pull-policy=IfNotPresent
REPOSITORY                                                   TAG                         IMAGE ID       CREATED        SIZE
postgres                                                     12                          3d6880d04326   2 weeks ago    373MB
lh-develop.img                                               latest                      f26c3c667fbe   5 weeks ago    2.82GB
dpage/pgadmin4                                               latest                      4d5afde0a02e   6 weeks ago    361MB
detector                                                     latest                      e6f7e6567b73   7 weeks ago    3.81GB
lh-detetctor.img                                             latest                      e6f7e6567b73   7 weeks ago    3.81GB
registry.dev.mpksoft.ru/lighthouse/lh-detector/lh-detector   current                     e6f7e6567b73   7 weeks ago    3.81GB

CodePudding user response:

If you are running the microK8s and Docker still it's necessary microk8s to have an idea about the docker that is running on your machine. local Docker daemon is not part of the MicroK8s Kubernetes cluster.

You can export the image and inject to cache

docker save <image name> > myimage.tar
microk8s ctr image import myimage.tar

Ref : doc

  • Related