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

 

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