退出重新启动失败的容器 - 在 Minikube 中同步 pod 时出错

退出重新启动失败的容器 - 在 Minikube 中同步 pod 时出错

我在尝试创建 pod 时遇到了这个错误。即使是 Ubuntu、Alpine 等非常常见的镜像也会出现这种情况。我对 Kubernetes 还不太熟悉,使用的是Minikube 节点(版本 v0.24.1)

命令:

kubectl run ubuntu --image==ubuntu

错误

Back-off restarting failed container - Error syncing pod

版本:

  • Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"**v1.8.0**", GitCommit:"6e937839ac04a38cac63e6a7a306c5d035fe7b0a", GitTreeState:"clean", BuildDate:"2017-09-28T22:57:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

  • Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"**v1.8.0**", GitCommit:"0b9efaeb34a2fc51ff8e4d34ad9bc6375459c4a4", GitTreeState:"clean", BuildDate:"2017-11-29T22:43:34Z", GoVersion:"go1.9.1", Compiler:"gc", Platform:"linux/amd64"}

描述 Pod 命令:

Name:           ubuntunew-7567df64b8-mwc7x
Namespace:      default
Node:           minikube/192.168.99.102
Start Time:     Tue, 31 Jul 2018 14:48:35 +0530
Labels:         pod-template-hash=3123892064
                run=ubuntunew
Annotations:    kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"ubuntunew-7567df64b8","uid":"b3ba5547-94a2-11e8-91ce-080027df8e9...
Status:         Running
IP:             172.17.0.4
Created By:     ReplicaSet/ubuntunew-7567df64b8
Controlled By:  ReplicaSet/ubuntunew-7567df64b8
Containers:
  ubuntunew:
    Container ID:   docker://7871bcbd8a42164fd1168ed1955b75583e16d779fb609d39ebbb2c871e855b3b
    Image:          ubuntu
    Image ID:       docker-pullable://ubuntu@sha256:3f119dc0737f57f704ebecac8a6d8477b0f6ca1ca0332c7ee1395ed2c6a82be7
    Port:           <none>
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Tue, 31 Jul 2018 15:02:53 +0530
      Finished:     Tue, 31 Jul 2018 15:02:53 +0530
    Ready:          False
    Restart Count:  7
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-8nj4d (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          False 
  PodScheduled   True 
Volumes:
  default-token-8nj4d:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-8nj4d
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     <none>
Events:
  Type     Reason                 Age                 From               Message
  ----     ------                 ----                ----               -------
  Normal   Scheduled              15m                 default-scheduler  Successfully assigned ubuntunew-7567df64b8-mwc7x to minikube
  Normal   SuccessfulMountVolume  15m                 kubelet, minikube  MountVolume.SetUp succeeded for volume "default-token-8nj4d"
  Warning  BackOff                13m (x4 over 14m)   kubelet, minikube  Back-off restarting failed container
  Normal   Pulled                 13m (x4 over 14m)   kubelet, minikube  Successfully pulled image "ubuntu"
  Normal   Created                13m (x4 over 14m)   kubelet, minikube  Created container
  Normal   Started                13m (x4 over 14m)   kubelet, minikube  Started container
  Normal   Pulling                10m (x6 over 15m)   kubelet, minikube  pulling image "ubuntu"
  Warning  FailedSync             39s (x52 over 14m)  kubelet, minikube  Error syncing pod

奇怪的是,它适用于 nginx 图像。

答案1

根据Describe Pod命令列表,Pod 内的容器已完成exit code 0,这表明已成功完成且没有任何错误/问题,但的生命周期Pod非常短。要使 Pod 持续运行,您必须指定一个永不完成的任务。

apiVersion: v1
kind: Pod
metadata:
  name: ubuntu
spec:
  containers:
  - name: ubuntu
    image: ubuntu
    command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]

你可以找到更多提示这里

相关内容