pugazhendhi_r
pugazhendhi_r

Reputation: 101

how to connect kubernetes cluster with image registry

Hi I have deployed 3 node kubernetes cluster (one master, 2 worker nodes) as below:

kubectl get nodes
NAME                 STATUS   ROLES           AGE    VERSION
master.domain.com    Ready    control-plane   161m   v1.24.4
worker1.domain.com   Ready    <none>          154m   v1.24.4
worker2.domain.com   Ready    <none>          153m   v1.24.4

I used cri-o container run time, tried creating few pods but it is failing with below events:

Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  40s                default-scheduler  Successfully assigned default/nginx to worker2.domain.com
  Normal   BackOff    26s                kubelet            Back-off pulling image "nginx"
  Warning  Failed     26s                kubelet            Error: ImagePullBackOff
  Normal   Pulling    11s (x2 over 32s)  kubelet            Pulling image "nginx"
  Warning  Failed     2s (x2 over 27s)   kubelet            Failed to pull image "nginx": rpc error: code = Unknown desc = Error reading manifest latest in registry.hub.docker.com/nginx: unauthorized: authentication required
  Warning  Failed     2s (x2 over 27s)   kubelet            Error: ErrImagePull

The pod definition file is below:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    app: frontend
spec:
  containers:
    - name: nginx
      image: nginx

Same like this I tried with mysql instead of nginx, I'm getting below events in the mysql pod, looks like it is able to pull the image but not able to run the pod:

  Type     Reason     Age                   From               Message
  ----     ------     ----                  ----               -------
  Normal   Scheduled  23m                   default-scheduler  Successfully assigned default/mysql to worker1.domain.com
  Normal   Pulled     22m                   kubelet            Successfully pulled image "mysql" in 54.067277637s
  Normal   Pulled     22m                   kubelet            Successfully pulled image "mysql" in 18.227802182s
  Normal   Pulled     21m                   kubelet            Successfully pulled image "mysql" in 13.511077504s
  Normal   Created    20m (x4 over 22m)     kubelet            Created container mysql
  Normal   Started    20m (x4 over 22m)     kubelet            Started container mysql
  Normal   Pulled     20m                   kubelet            Successfully pulled image "mysql" in 11.998942705s
  Normal   Pulling    20m (x5 over 23m)     kubelet            Pulling image "mysql"
  Normal   Pulled     20m                   kubelet            Successfully pulled image "mysql" in 13.68976309s
  Normal   Pulled     18m                   kubelet            Successfully pulled image "mysql" in 16.584670292s
  Warning  BackOff    3m12s (x80 over 22m)  kubelet            Back-off restarting failed container

below is the POD status:

NAME    READY   STATUS             RESTARTS        AGE
mysql   0/1     CrashLoopBackOff   8 (4m51s ago)   23m
nginx   0/1     ImagePullBackOff   0               3m26s

Upvotes: 0

Views: 133

Answers (1)

Adiii
Adiii

Reputation: 60074

You do not really need any extra config to pull image from public image registry

The containers/image library is used for pulling images from registries. Currently, it supports Docker schema 2/version 1 as well as schema 2/version 2. It also passes all Docker and Kubernetes tests.

cri-container-images

So just mention the image with the right URI and it should work.

Upvotes: 1

Related Questions