问题描述
运行容器命令:
[root@master-149 ~]# kubectl run my-alpine --image=alpine --replicas=2 ping www.baidu.com
查看pods状态
[root@master-149 ~]# kubectl get podsNAME READY STATUS RESTARTS AGEmy-alpine-2150523991-knzcx 0/1 ContainerCreating 0 6mmy-alpine-2150523991-lmvv5 0/1 ContainerCreating 0 6m
问题解答
回答1:使用kubectl describe pod my-alpine-2150523991-knzcx查看pod在创建的过程中的事件,或许有惊喜
回答2:根据1楼的回复找到了解决办法:执行如下命令:
[root@master-149 ~]# kubectl describe pod my-alpineName:my-alpine-2150523991-knzcxNamespace: defaultNode:node-150/192.168.10.150Start Time: Sat, 19 Nov 2016 18:20:52 +0800Labels:pod-template-hash=2150523991,run=my-alpineStatus:PendingIP:Controllers: ReplicaSet/my-alpine-2150523991Containers: 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: 0 Environment Variables:Conditions: TypeStatus Ready False No volumes.Events: FirstSeen LastSeen Count From SubobjectPath TypeReasonMessage --------- -------- ----- ---- ------------- -------- ------------- 7m7m1 {default-scheduler } NormalScheduled Successfully assigned my-alpine-2150523991-knzcx to node-150 6m6m1 {kubelet node-150} WarningFailedSync 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 refusedn v1 ping attempt failed with error: Get https://gcr.io/v1/_ping: dial tcp 64.233.189.82:443: getsockopt: connection refused)' 4m 47s 3 {kubelet node-150}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 refusedn v1 ping attempt failed with error: Get https://gcr.io/v1/_ping: dial tcp 74.125.204.82:443: getsockopt: connection refused)' 4m 8s 6 {kubelet node-150}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-2150523991-lmvv5Namespace: defaultNode:node-150/192.168.10.150Start Time: Sat, 19 Nov 2016 18:20:52 +0800Labels:pod-template-hash=2150523991,run=my-alpineStatus:PendingIP:Controllers: ReplicaSet/my-alpine-2150523991Containers: 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: 0 Environment Variables:Conditions: TypeStatus Ready False No volumes.Events: FirstSeen LastSeen Count From SubobjectPath TypeReasonMessage --------- -------- ----- ---- ------------- -------- ------------- 7m7m1 {default-scheduler } NormalScheduled Successfully assigned my-alpine-2150523991-lmvv5 to node-150 5m1m3 {kubelet node-150} WarningFailedSync 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 refusedn v1 ping attempt failed with error: Get https://gcr.io/v1/_ping: dial tcp 74.125.204.82:443: getsockopt: connection refused)' 3m 1m 4 {kubelet node-150}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 refusedn 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文件
从其他源下载容器“pause:2.0”,然后打tag为“gcr.io/google_containers/pause:2.0”
回答3:gcr.io被墙了,可以给kubelet加上一个参数--pod-infra-container-image来指定一个国内的镜像。
我们搬了一个image到registry.aliyuncs.com/archon/pause-amd64:3.0,可以用它。

