Kubernetes-部署Pod时出现错误消息ImagePullBackOff [英] Kubernetes - Error message ImagePullBackOff when deploy a pod

查看:181
本文介绍了Kubernetes-部署Pod时出现错误消息ImagePullBackOff的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好kubernetes开发人员,

Hello kubernetes developers,

如果在kubernetes中部署pod,我会收到错误消息"ImagePullBackOff". 拉入docker从git-hub仓库获取图像是没有问题的.但是我的配置出了什么问题?

i get the error 'ImagePullBackOff' if deploy a pod in kubernetes. Pulling in docker to get the image from git-hub repository is no problem. But what is wrong with my configuration?

我尝试了以下变通方法,以使用以下命令创建密钥.

I tried this workaround to create a secret-key with the following command.

kubectl create secret docker-registry secretkey \
        --docker-server=registry.hub.docker.com \
        --docker-username=reponame \
        --docker-password=repopassword \
        --docker-email=repoemail

这是用于创建kubernetes容器的yaml文件.

And this is the yaml file to create the kubernetes pod.

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: gps-restful-server
  name: gps-restful-server
spec:
  containers:
  - image: tux/gps:latest
    name: gps-restful-server
    ports:
    - containerPort: 8080
    resources: {}
    volumeMounts:
    - mountPath: /var/www/html/modules
      name: gps-modules
    - mountPath: /var/www/html/profiles
      name: gps-profile
    - mountPath: /var/www/html/themes
      name: gps-theme
    - mountPath: /var/www/html/sites
      name: gps-sites
    imagePullPolicy: Always
  restartPolicy: OnFailure
  imagePullSecrets:
    - name: secretkey
  volumes:
  - name: gps-modules
    persistentVolumeClaim:
      claimName: gps-modules
  - name: gps-profile
    persistentVolumeClaim:
      claimName: gps-profile
  - name: gps-theme
    persistentVolumeClaim:
      claimName: gps-theme
  - name: gps-sites
    persistentVolumeClaim:
      claimName: gps-sites
status: {}

要在kubernetes中部署pod,我要执行以下命令:

To deploy the pod in kubernetes, i execute the command:

kubectl create -f gps-restful-server-pod.yaml.

从窗格中获取状态:

kubectl get all
NAME                           READY     STATUS             RESTARTS   AGE
pod/telemetry-restful-server   0/1       ImagePullBackOff   0          12m  
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP    1h

吊舱说明:

kubectl describe pod gps-restful-server
Name:               gps-restful-server
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               minikube/192.168.178.92
Start Time:         Thu, 14 Feb 2019 16:56:25 +0100
Labels:             io.kompose.service=gps-restful-server
Annotations:        <none>
Status:             Pending
IP:                 172.17.0.3
Containers:
  gps-restful-server:
    Container ID:
    Image:          tux/gps:latest
    Image ID:
    Port:           8080/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-4t28k (ro)
      /var/www/html/modules from gps-modules (rw)
      /var/www/html/profiles from gps-profile (rw)
      /var/www/html/sites from gps-sites (rw)
      /var/www/html/themes from gps-theme (rw)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  gps-modules:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  gps-modules
    ReadOnly:   false
  gps-profile:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  gps-profile
    ReadOnly:   false
  gps-theme:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  gps-theme
    ReadOnly:   false
  gps-sites:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  gps-sites
    ReadOnly:   false
  default-token-4t28k:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-4t28k
    Optional:    false
QoS Class:       BestEffort
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 default/gps-restful-server to minikube
  Normal   Pulling    2m (x4 over 4m)  kubelet, minikube  pulling image "tux/gps:latest"
  Warning  Failed     2m (x4 over 4m)  kubelet, minikube  Failed to pull image "tux/gps:latest": rpc error: code = Unknown desc = Error response from daemon: pull access denied for tux/gps, repository does not exist or may require 'docker login'
  Warning  Failed     2m (x4 over 4m)  kubelet, minikube  Error: ErrImagePull
  Warning  Failed     2m (x6 over 4m)  kubelet, minikube  Error: ImagePullBackOff
  Normal   BackOff    2m (x7 over 4m)  kubelet, minikube  Back-off pulling image "tux/gps:latest"

如何在kubernetes中从docker-hub中提取图像?

How it's possible to pull the image from docker-hub in kubernetes?

推荐答案

图像tux/gps:latest不存在,因为它是一个伪值. ImagePullBackoff解决方案:

The Image tux/gps:latest does not exist because its a dummy value. Solution to ImagePullBackoff:

  1. 确保您的映像指向最新版本的repouser/reponame:latest
  2. 创建一个秘密的docker-registry(如上所示)
  3. 服务器地址[ docker-hub注册表]
  4. 在pod yaml文件中添加以下属性(如上所示):
  1. Make sure that your Image points to latest version repouser/reponame:latest
  2. Create a secret docker-registry (look above)
  3. Server address[docker-hub registry]
  4. Add the following propertie in pod yaml file (look above):

imagePullSecrets:
-名称:secretkey

imagePullSecrets:
- name: secretkey

这篇关于Kubernetes-部署Pod时出现错误消息ImagePullBackOff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆