pod的状态一直为 ContainerCreating的问题排查

自己学习通过kubernetes binary手工搭建集群时遇到的问题。

测试集群时,运行pod。

[root@k8s01 work]# kubectl run my-nginx --image=nginx:1.7.9 --replicas=2 
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/my-nginx created

检查pod状态,发现pod的状态一直在创建过程中,而不是running状态。

[root@k8s01 work]# kubectl get pod
NAME                        READY   STATUS              RESTARTS   AGE
my-nginx-5c777454cd-pf89v   0/1     ContainerCreating   0          10s
my-nginx-5c777454cd-q4bl9   0/1     ContainerCreating   0          10s

查看pod的详细信息。

[root@k8s01 work]# kubectl describe pod my-nginx
Name:           my-nginx-5c777454cd-pf89v
Namespace:      default
Priority:       0
Node:           k8s01/192.168.115.191
Start Time:     Fri, 03 Jul 2020 11:56:29 +0800
Labels:         pod-template-hash=5c777454cd
                run=my-nginx
Annotations:    <none>
Status:         Pending
IP:             
IPs:            <none>
Controlled By:  ReplicaSet/my-nginx-5c777454cd
Containers:
  my-nginx:
    Container ID:   
    Image:          nginx:1.7.9
    Image ID:       
    Port:           <none>
    Host Port:      <none>
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-hq4cn (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  default-token-hq4cn:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-hq4cn
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 360s
                 node.kubernetes.io/unreachable:NoExecute for 360s
Events:
  Type     Reason                  Age        From               Message
  ----     ------                  ----       ----               -------
  Normal   Scheduled               <unknown>  default-scheduler  Successfully assigned default/my-nginx-5c777454cd-pf89v to k8s01
  Warning  FailedCreatePodSandBox  32s        kubelet, k8s01     Failed create pod sandbox: rpc error: code = Unknown desc = failed pulling image "k8s.gcr.io/pause:3.1": Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

看到后面最后一行:

Warning  FailedCreatePodSandBox  32s        kubelet, k8s01     Failed create pod sandbox: rpc error: code = Unknown desc = failed pulling image "k8s.gcr.io/pause:3.1": Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

是由于k8s.gcr.io/pause:3.1无法下载导致。

我的电脑不能上网,nginx:1.7.9是事先导入的。

通过下载k8s.gcr.io/pause:3.1镜像,然后导入集群主机。

docker load -i /opt/k8s/work/k8s.gcr.io_pause.3.1.tar

再检查pod的状态,状态为running了。

[root@k8s01 work]# kubectl get pod
NAME                        READY   STATUS    RESTARTS   AGE
my-nginx-5c777454cd-pf89v   1/1     Running   0          15m
my-nginx-5c777454cd-q4bl9   1/1     Running   0          15m

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章