Docker K8s 04 kubectl create 之后一直处于 Pending 状态

错误描述

在使用 kubectl create 创建 pod 服务之后, kubectl describe pods 查看状态, 可能会发现一直处于等待中状态.

1
2
3
4
5
Status:	Pending
Reason: ContainerCreating

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)

详细的信息大致如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Name:		nginx-controller-8pxdt
Namespace: default
Node: 192.168.1.9/192.168.1.9
Start Time: Sun, 08 Dec 2019 12:27:40 +0800
Labels: name=nginx
Status: Pending
IP:
Controllers: ReplicationController/nginx-controller
Containers:
nginx:
Container ID:
Image: nginx
Image ID:
Port: 80/TCP
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
--------- -------- ----- ---- ------------- -------- ------ -------
17m 17m 1 {default-scheduler } Normal Scheduled Successfully assigned nginx-controller-8pxdt to 192.168.1.9
17m 1m 8 {kubelet 192.168.1.9} 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)"

17m 10s 73 {kubelet 192.168.1.9} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redhat.com/rhel7/pod-infrastructure:latest\""

解决方案

在 Node 节点上, 修改 /etc/kubernetes/kubelet 文件, 注释掉配置 KUBELET_POD_INFRA_CONTAINER

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

参考文档: Unable to pull images in Kubernetes

Donate - Support to make this site better.
捐助 - 支持我让我做得更好.