Kubernetes部署因映像拉拔失败而失败

时间:2019-01-09 09:59:05

标签: kubernetes google-compute-engine kubectl google-kubernetes-engine

当尝试将我的自定义nginx映像从本地注册表部署到kubernetes时,我在kubernetes-dashboard中看到以下错误-

无法拉取映像“ myapp”:rpc错误:代码=未知desc =来自守护程序的错误响应:找不到存储库myapp:不存在或没有拉取访问权限

这是我遵循的步骤-

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

在Kubernetes-dashboard中,由于未找到存储库myapp错误,我看到部署显示失败。

我什至尝试添加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

但还是同样的问题。

我应该怎么做才能在GKE中获得本地仓库。 感谢任何帮助。谢谢。

这是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

1 个答案:

答案 0 :(得分:0)

这里的问题是您的吊舱正在工作节点上,并且工作节点上没有import matplotlib.pyplot as plt import numpy as np import matplotlib.animation as animation def update_fig(num, data, plot, ax) : text = None if num % 2 == 0 : text = ax.text(0.5, 0.5, str(num), horizontalalignment='center', verticalalignment='center', transform=ax.transAxes,size=15) plot.set_array(data[:, :, num %1500].ravel()) if text : return pp_color, text, else : return pp_color, fig, ax = plt.subplots() data = np.random.rand(60, 50, 1500) pp_color = plt.pcolormesh(data[:,:, 0], cmap = 'Reds', vmin=np.amin(data), vmax=np.amax(data)) cbar = plt.colorbar() t1 = cbar.ax.set_title('t1') plt.axis('equal') ax.text(0.5, -0.1, 'footnote text', horizontalalignment='center', transform=ax.transAxes,) t2 = ax.set_title("t2") line_ani = animation.FuncAnimation(fig, update_fig, interval=0.1, blit=True, fargs=(data, pp_color, ax)) plt.show() 图片。

您需要按如下方式将mynginx映像从主节点复制到工作节点:

在主节点上运行以下命令:

mynginx

现在将生成的tar文件复制到工作节点并使用以下命令加载该图像:

docker save -o <path for generated tar file> mynginx

这会将docker load -i <path to image tar file> 图片加载到您的工作节点上,并且可以解决您的问题