[英]Kubernetes deployment failing due to Image pull failure
While trying to deploy my custom nginx image from local registry to kubernetes , I am seeing below error in kubernetes-dashboard - 尝试将自定义nginx映像从本地注册表部署到kubernetes时,我在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 无法拉取映像“ myapp”:rpc错误:代码=未知desc =来自守护程序的错误响应:找不到存储库myapp:不存在或没有拉取权限
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. 在Kubernetes-dashboard中,由于未找到存储库myapp错误,我看到部署显示失败。
I even tried to add this steps mentioned in https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ 我什至尝试添加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. 我应该为Pod做些什么,以便在GKE中获得本地存储库。 Appreciate any help. 感谢任何帮助。 Thanks. 谢谢。
Here is the more info as requested by rjdkolb - 这是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. 这里的问题是您的pod正在工作节点上运行,并且工作节点上没有mynginx
映像。
You need to copy the mynginx image from master node to worker node as follows: 您需要按如下方式将mynginx映像从主节点复制到工作节点:
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: 现在,将生成的tar文件复制到工作节点并使用以下命令加载该映像:
docker load -i <path to image tar file>
This will load the mynginx
image on your worker node and it will resolve your issue 这将在您的工作节点上加载mynginx
图像,并将解决您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.