1个月前 (07-16) 铁匠  Docker
文章评分 1 次,平均分 4.0

最近刚刚入手研究kubernetes,运行容器的时候,发现一直处于ContainerCreating状态,悲了个催,刚入手就遇到了点麻烦,下面来讲讲如何查找问题及解决的

运行容器命令:

[root@master-149 ~]# kubectl run my-alpine --image=alpine --replicas=2 ping www.baidu.com

查看pods状态

[root@master-149 ~]# kubectl get pods
NAME                         READY     STATUS              RESTARTS   AGE
my-alpine-2150523991-knzcx   0/1       ContainerCreating   0          6m
my-alpine-2150523991-lmvv5   0/1       ContainerCreating   0          6m

一直处于ContainerCreating状态,开始查找原因

执行如下命令:


[root@master-149 ~]# kubectl describe pod my-alpine
Name:		my-alpine-2150523991-knzcx
Namespace:	default
Node:		node-150/192.168.10.150
Start Time:	Sat, 19 Nov 2016 18:20:52 +0800
Labels:		pod-template-hash=2150523991,run=my-alpine
Status:		Pending
IP:		
Controllers:	ReplicaSet/my-alpine-2150523991
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:	0
    Environment Variables:
Conditions:
  Type		Status
  Ready 	False 
No volumes.
Events:
  FirstSeen	LastSeen	Count	From			SubobjectPath	Type		Reason		Message
  ---------	--------	-----	----			-------------	--------	------		-------
  7m		7m		1	{default-scheduler }			Normal		Scheduled	Successfully assigned my-alpine-2150523991-knzcx to node-150
  6m		6m		1	{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 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	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 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	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-lmvv5
Namespace:	default
Node:		node-150/192.168.10.150
Start Time:	Sat, 19 Nov 2016 18:20:52 +0800
Labels:		pod-template-hash=2150523991,run=my-alpine
Status:		Pending
IP:		
Controllers:	ReplicaSet/my-alpine-2150523991
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:	0
    Environment Variables:
Conditions:
  Type		Status
  Ready 	False 
No volumes.
Events:
  FirstSeen	LastSeen	Count	From			SubobjectPath	Type		Reason		Message
  ---------	--------	-----	----			-------------	--------	------		-------
  7m		7m		1	{default-scheduler }			Normal		Scheduled	Successfully assigned my-alpine-2150523991-lmvv5 to node-150
  5m		1m		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 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	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 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”




//下面这个css和插件后台设置的主题有关系,如果需要换样式,则需要修改以下CSS名称

  
 

除特别注明外,本站所有文章均为铁匠运维网原创,转载请注明出处来自http://www.tiejiang.org/24257.html

关于

发表评论

暂无评论

切换注册

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

切换登录

注册

扫一扫二维码分享