无法在 Kubernetes 中拉取镜像

无法在 Kubernetes 中拉取镜像

我在 CentOS 7 上运行 Kubernetes,但无法部署 pod。运行后

# kubectl run nginx --image=nginx

我跑

# kubectl describe pod nginx

给出以下输出:

Name:           nginx-701339712-8sx7m
Namespace:      default
Node:           node2/192.168.1.126
Start Time:     Fri, 27 Oct 2017 14:06:35 -0400
Labels:         pod-template-hash=701339712
                run=nginx
Status:         Pending
IP:
Controllers:    ReplicaSet/nginx-701339712
Containers:
  nginx:
    Container ID:
    Image:                      nginx
    Image ID:
    Port:
    State:                      Waiting
      Reason:                   ContainerCreating
    Ready:                      False
    Restart Count:              0
    Volume Mounts:              <none>
    Environment Variables:      <none>
Conditions:
  Type          Status
  Initialized   True
  Ready         False
  PodScheduled  True
No volumes.
QoS Class:      BestEffort
Tolerations:    <none>
Events:
  FirstSeen     LastSeen        Count   From                    SubObjectPath   Type            Reason          Message
  ---------     --------        -----   ----                    -------------   --------        ------          -------
  21s           21s             1       {default-scheduler }                    Normal          Scheduled       Successfully assigned nginx-701339712-8sx7m to node2
  21s           7s              2       {kubelet node2}                         Warning         FailedSync      Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request.  details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)"

如果滚动最后一行,您会看到它会转到 redhat.com 并且失败。我不知道为什么要到 RedHat 仓库进行镜像拉取;它应该从 docker hub 拉取。

答案1

我通过评论这一行解决了这个问题:

KUBELET_POD_INFRA_CONTAINER="--pod-infra-containerimage=registry.access.redhat.com/rhel7/pod-infrastructure:latest"

在 /etc/kubernetes/kubelet 中

在我的每一个奴隶身上

答案2

不建议编辑 /etc/kubernetes/kubelet 来解决此错误。如果您看到registry.access.redhat.com/rhel7/pod-infrastruct:latest 的镜像拉取失败,您可以尝试运行命令:

百胜安装-yrhsm

运行命令后我解决了同样的错误。

相关内容