运行容器的时候,发现一直处于ContainerCreating状态,悲了个催,刚入手就遇到了点麻烦,下面来讲讲如何查找问题及解决的
运行容器命令:
[root@master- ~]# kubectl run my-alpine --image=alpine --replicas= ping www.baidu.com
查看pods状态
[root@master- ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
my-alpine--knzcx / ContainerCreating 6m
my-alpine--lmvv5 / ContainerCreating 6m
一直处于ContainerCreating状态,开始查找原因
执行如下命令:
[root@master- ~]# kubectl describe pod my-alpine
Name: my-alpine--knzcx
Namespace: default
Node: node-/192.168.10.150
Start Time: Sat, Nov :: +
Labels: pod-template-hash=,run=my-alpine
Status: Pending
IP:
Controllers: ReplicaSet/my-alpine-
Containers:
my-alpine:
Container ID:
Image: alpine
Image ID:
Port:
Args:
ping
www.baidu.com
QoS Tier:
cpu: BestEffort
memory: BestEffort
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count:
Environment Variables:
Conditions:
Type Status
Ready False
No volumes.
Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
7m 7m {default-scheduler } Normal Scheduled Successfully assigned my-alpine--knzcx to node-
6m 6m {kubelet node-} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for gcr.io/google_containers/pause:2.0, this may be because there are no credentials on this request. details: (unable to ping registry endpoint https://gcr.io/v0/\nv2 ping attempt failed with error: Get https://gcr.io/v2/: dial tcp 64.233.189.82:443: getsockopt: connection refused\n v1 ping attempt failed with error: Get https://gcr.io/v1/_ping: dial tcp 64.233.189.82:443: getsockopt: connection refused)" 4m 47s {kubelet node-} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for gcr.io/google_containers/pause:2.0, this may be because there are no credentials on this request. details: (unable to ping registry endpoint https://gcr.io/v0/\nv2 ping attempt failed with error: Get https://gcr.io/v2/: dial tcp 74.125.204.82:443: getsockopt: connection refused\n v1 ping attempt failed with error: Get https://gcr.io/v1/_ping: dial tcp 74.125.204.82:443: getsockopt: connection refused)" 4m 8s {kubelet node-} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"gcr.io/google_containers/pause:2.0\"" Name: my-alpine--lmvv5
Namespace: default
Node: node-/192.168.10.150
Start Time: Sat, Nov :: +
Labels: pod-template-hash=,run=my-alpine
Status: Pending
IP:
Controllers: ReplicaSet/my-alpine-
Containers:
my-alpine:
Container ID:
Image: alpine
Image ID:
Port:
Args:
ping
www.baidu.com
QoS Tier:
cpu: BestEffort
memory: BestEffort
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count:
Environment Variables:
Conditions:
Type Status
Ready False
No volumes.
Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
7m 7m {default-scheduler } Normal Scheduled Successfully assigned my-alpine--lmvv5 to node-
5m 1m {kubelet node-} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for gcr.io/google_containers/pause:2.0, this may be because there are no credentials on this request. details: (unable to ping registry endpoint https://gcr.io/v0/\nv2 ping attempt failed with error: Get https://gcr.io/v2/: dial tcp 74.125.204.82:443: getsockopt: connection refused\n v1 ping attempt failed with error: Get https://gcr.io/v1/_ping: dial tcp 74.125.204.82:443: getsockopt: connection refused)" 3m 1m {kubelet node-} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"gcr.io/google_containers/pause:2.0\""
其中: Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for gcr.io/google_containers/pause:2.0, this may be because there are no credentials on this request. details: (unable to ping registry endpoint https://gcr.io/v0/\nv2 ping attempt failed with error: Get https://gcr.io/v2/: dial tcp 74.125.204.82:443: getsockopt: connection refused\n v1 ping attempt failed with error: Get https://gcr.io/v1/_ping: dial tcp 74.125.204.82:443: getsockopt: connection refused)
不难看出,无法访问到gcr.io
有如下解决办法:
- *
- 修改hosts文件(这里我用的是“61.91.161.217 gcr.io”,但是可能会失效)
- 从其他源下载容器“pause:2.0”,然后打tag为“gcr.io/google_containers/pause:2.0”