Create Kubernetes pod from private registry

12/18/2017

I'm traying to create a Pod from a docker private image. For this i have created a secret like this:

kubectl create secret docker-registry $SECRETNAME --docker-server=$DOCKER_REGISTRY_SERVER --docker-username=$DOCKER_USER --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL

and then in the pod yml file,

apiVersion: v1
kind: Pod
metadata:
  name: website.com
  labels: 
    app: website
spec:
  containers:
  - name: my-web
    image: company/web:1.0.2
    imagePullPolicy: Always
    command: [ "echo", "SUCCESS" ]
    ports:
    - name: web-port
      containerPort: 8080
  imagePullSecrets:
    - name: docker-hub-key

When I run "kubectl create -f web-pod.yml", and then I run "kubectl get pod website.com" I get the following error:

  • Failed to pull image "company/web:1.0.2": rpc error: code = Unknown desc = Error response from daemon: repository company/web not found: does not exist or no pull access
  • Back-off pulling image "company/web:1.0.2"

Please help, thanks in advance

-- Algoleigol
kubernetes

1 Answer

12/20/2017

Since the fail is at the initial stage, this is probably an issue with authentication or repository-(image/tags access). Please verify that the repository name is valid and that the image version specified is available in the repository.

If all has been verified and the issue still persists, try do the following:

  • Restart docker service daemon
  • Check to confirm that the secret provided for the repo is valid
  • Try pull the image using kubectl command like below:

    $ kubectl run <deployment-name> --image=<repo>/<image>:<version> --port=8080

If the above command is successful, then it will help you rule out auth/access issues. If the issue is not solved, go through the logs to get more specifics on the problem.

-- Oron Zimmer
Source: StackOverflow