Kubernetes doesn't pull from private Docker Registry

5/6/2016

I've deployed a private registry and can pull from it with docker pull x.x.x/name. The thing is that I can't make Kubernetes pull from that repository. I think I've followed all the answers on other topics, but they don't seem to do the trick.

.yaml file:

apiVersion: v1
kind: Pod
metadata:
  name: private-image-test-1
spec:
  containers:
    - name: uses-private-image
      image: x.x.x/nginx_1
      imagePullPolicy: Always
      command: [ "echo", "SUCCESS" ]
  imagePullSecrets:
   - name: registrypullsecret

kubectl get pods:

NAME                   READY     STATUS                                                                 RESTARTS   AGE
private-image-test-1   0/1       Image: x.x.x/nginx_1 is ready, container is creating   0          4m

kubectl describe pods private-image-test-1

Name:           private-image-test-1
Namespace:      default
Node:           37.72.163.69/37.72.163.69
Start Time:     Fri, 06 May 2016 08:04:45 +0000
Labels:         <none>
Status:         Pending
IP:
Controllers:    <none>
Containers:
  uses-private-image:
    Container ID:
    Image:              x.x.x/nginx_1
    Image ID:
    Port:
    Command:
      echo
      SUCCESS
    QoS Tier:
      cpu:              BestEffort
      memory:           BestEffort
    State:              Waiting
      Reason:           Image: x.x.x/nginx_1 is ready, container is creating
    Ready:              False
    Restart Count:      0
    Environment Variables:
Conditions:
  Type          Status
  Ready         False 
Volumes:
  default-token-zrn4n:
    Type:       Secret (a volume populated by a Secret)
    SecretName: default-token-zrn4n
Events:
  FirstSeen     LastSeen        Count   From                    SubobjectPath                           Type            Reason        Message
  ---------     --------        -----   ----                    -------------                           --------        ------        -------
  4m            4m              1       {scheduler }                                                                    scheduled     Successfully assigned private-image-test-1 to 37.72.163.69
  4m            8s              30      {kubelet 37.72.163.69}  implicitly required container POD                       pulled        Successfully pulled image "gcr.io/google_containers/pause:0.8.0"
  4m            8s              30      {kubelet 37.72.163.69}  implicitly required container POD                       failed        Failed to create docker container with error: no such image
  4m            8s              30      {kubelet 37.72.163.69}                                                          failedSync    Error syncing pod, skipping: no such image

Any help is welcome at this point, thanks!

-- Zwadderich
docker
kubernetes
private
registry

1 Answer

5/9/2016

In most cases where I've come across this issue, it is almost always your credential secret being incorrect. The proper format should be along the lines of

apiVersion: v1
kind: Secret
metadata:
  name: registrypullsecret
data:
  .dockerconfigjson: {BASE64 encoding of your config}
type: kubernetes.io/dockerconfigjson

From memory, the type field has changed in recent versions of k8s so definitely check that you have the correct type listed.

Also, your yaml example has bad indenting, but thats likely a SO editor issue.

-- Ian Belcher
Source: StackOverflow