Getting ImagePullBackOff when starting a POD is AWS EKS

6/8/2020

I am getting the following error when my pod is deployed and then it tries to pull the image.

Failed to pull image "foyer-api:latest": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/library/foyer-api:latest": failed to resolve reference "docker.io/library/foyer-api:latest": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

Here is the Pod Yaml

apiVersion: v1
kind: Pod
metadata:
  name: foyer-api-test
  labels:
    app: foyer-api-test
spec:
  containers:
    - name: foyer-api
      image: foyer-api:latest
      ports:
       - containerPort: 80
-- Michael McDermott
amazon-ecr
amazon-eks
docker
kubernetes

1 Answer

6/8/2020

To pull an Image from a Private Registry click here

Basically you need to create a secret using docker credential. For example, using command line

$ kubectl create secret docker-registry regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>

Then use it in imagePullSecrets

apiVersion: v1
kind: Pod
metadata:
  name: foyer-api-test
  labels:
    app: foyer-api-test
spec:
  containers:
  - name: foyer-api
    image: foyer-api:latest
    ports:
    - containerPort: 80
  imagePullSecrets:
  - name: regcred
-- hoque
Source: StackOverflow