While trying to deploy my custom nginx image from local registry to kubernetes , I am seeing below error in kubernetes-dashboard -
Failed to pull image "myapp": rpc error: code = Unknown desc = Error response from daemon: repository myapp not found: does not exist or no pull access
This is the steps I followed -
1) Built my customer image using docker
2) kubectl run myapp --image=myapp --port=80 --image-pull-policy=IfNotPresent
3) kubectl expose deployment myapp --type=LoadBalancer --port=80 --target-port=80 --name=myapp
In Kubernetes-dashboard, I see deployment showing failure due to above error of repository myapp not found.
I even tried to add this steps mentioned in https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
docker login
kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username=xxx --docker-password=xxx --docker-email=xxx
But still same issue.
What should I do for pod to get my local repo in GKE. Appreciate any help. Thanks.
Here is the more info as requested by rjdkolb -
xxx@cloudshell:~ (involuted-ratio-227118)$ kubectl describe pod myapp-7cf96cf48-vsqb5
Name: myapp-7cf96cf48-vsqb5
Namespace: default
Node: gke-standard-cluster-1-default-pool-c7d671ed-br8j/10.142.0.3
Start Time: Wed, 09 Jan 2019 22:28:58 +0530
Labels: pod-template-hash=379527904
run=myapp
Annotations: kubernetes.io/limit-ranger=LimitRanger plugin set: cpu request for container myapp
Status: Pending
IP: 10.48.8.9
Controlled By: ReplicaSet/myapp-7cf96cf48
Containers:
myapp:
Container ID:
Image: mynginx
Image ID:
Port: 80/TCP
Host Port: 0/TCP
State: Waiting
Reason: ImagePullBackOff
Ready: False
Restart Count: 0
Requests:
cpu: 100m
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-8p622 (ro)
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
Volumes:
default-token-8p622:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-8p622
Optional: false
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 4m default-scheduler Successfully assigned myapp-7cf96cf48-vsqb5 to gke-standard-cluster-1-default-pool-c7d671ed-br8j
Normal SuccessfulMountVolume 4m kubelet, gke-standard-cluster-1-default-pool-c7d671ed-br8j MountVolume.SetUp succeeded for volume "default-token-8p622"
Normal Pulling 2m (x4 over 4m) kubelet, gke-standard-cluster-1-default-pool-c7d671ed-br8j pulling image "mynginx"
Warning Failed 2m (x4 over 4m) kubelet, gke-standard-cluster-1-default-pool-c7d671ed-br8j Failed to pull image "mynginx": rpc error: code = Unknown desc = Error response from daemon: repository mynginx not found: does not exist or no pull access
Warning Failed 2m (x4 over 4m) kubelet, gke-standard-cluster-1-default-pool-c7d671ed-br8j Error: ErrImagePull
Normal BackOff 2m (x6 over 4m) kubelet, gke-standard-cluster-1-default-pool-c7d671ed-br8j Back-off pulling image "mynginx"
Warning Failed 2m (x6 over 4m) kubelet, gke-standard-cluster-1-default-pool-c7d671ed-br8j Error: ImagePullBackOff
The issue here is your pod is going on the worker node and worker node doesn't have mynginx
image present.
You need to copy the mynginx image from master node to worker node as follows:
Run following command on master node:
docker save -o <path for generated tar file> mynginx
Now copy the generated tar file to the worker node and load that image using following command:
docker load -i <path to image tar file>
This will load the mynginx
image on your worker node and it will resolve your issue