Unable to pull docker image from local registry for Kubernetes deployment

I’ve a K8s cluster on Linode and another VM for operating.

I’ve installed Docker & K8s on operating VM to build images and do deployment on cluster.

Note: I haven’t installed minikube on this VM.

I’m able to build my image but not able to pull that from local registry to k8s pod.

Below are the things I’ve already done & tried to solve the problem.

  1. Create and push docker image to local registry.
  2. Run docker container from the image, but not getting pulled in K8s.
  3. Created “regcred” secret and used it in deployment yaml.
  4. create image and push with VM’s IP(10.128.234.123:5000/app-frontend) and use the same in deployment image reference.
  5. Change image pull policy to IfNotPresent

I get the following error in pod description:

  Warning  ErrImageNeverPull  11s (x4 over 13s)  kubelet            Container image "localhost:5000/app-frontend" is not present with pull policy of Never
  Warning  Failed             11s (x4 over 13s)  kubelet            Error: ErrImageNeverPull

Below is my deployment yaml:

  apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: app-frontend
      labels:
        app: app-frontend
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: app-frontend
      template:
        metadata:
          labels:
            app: app-frontend
        spec:
          containers:
            - name: app-frontend
              image: localhost:5000/docker-image
              imagePullPolicy: Never
              ports:
                - containerPort: 80
          imagePullSecrets:
          - name: regcred

Any help or guidance will be grateful.

Read more here: Source link