简体   繁体   English

为什么我执行 cmd 'kubectl get pods',pod 状态是 'NotReady'? 不合理,这个状态属于节点状态

[英]why i execute cmd 'kubectl get pods', the pod status is 'NotReady'? it's unreasonable, this status is belong to node status

ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/参考: https : //kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/

but the cmd result is(pod:two-containers status is NotReady ):但 cmd 结果是(pod:two-containers status is NotReady ):

[root@devnet-master ~]# kubectl get pods
NAME                             READY   STATUS     RESTARTS   AGE
busybox-1                        1/1     Running    1          33d
local-volume-provisioner-k49c7   1/1     Running    0          29m
nginx                            2/2     Running    1          21m
two-containers                   1/2     NotReady   0          61m

the version is:版本是:

[root@devnet-master ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-12T14:18:45Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-12T14:12:29Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/amd64"}

describe pod result is : exec describe pod result image描述 pod 结果是: exec 描述 pod 结果图像

apply yaml is: apply yaml image应用 yaml 是:应用 yaml 图像

apiVersion: v1
kind: Pod
metadata:
  name: two-containers
spec:
  restartPolicy: Never
  volumes:
  - name: shared-data
    hostPath:      
      path: /data
  containers:
  - name: nginx-container
    image: xxxxxx/nginx:1.0
    volumeMounts:
    - name: shared-data
      mountPath: /usr/share/nginx/html
  - name: debian-container
    image: xxxxxx/debian:stable
    volumeMounts:
    - name: shared-data
      mountPath: /pod-data
    command: ["/bin/sh"]
    args: ["-c", "echo Hello from the debian container > /pod-data/index.html"]

  • Pod is being shown in ready status because as per the screenshot you have provided it is a multi container pod. Pod 显示为就绪状态,因为根据您提供的屏幕截图,它是一个多容器 Pod。 Second container naemd "debian- container" is in "completed" state because it just had to execute a echo command.第二个容器 naemd "debian- container" 处于“已完成”状态,因为它只需要执行一个 echo 命令。 I suspect you have set the restartPolicy as Onfailure or Never so the pod is not restarting.我怀疑您已将 restartPolicy 设置为 Onfailure 或 Never,因此 pod 不会重新启动。 But one of the container inside the pod is in running state but the other is not.但是 pod 内的一个容器处于运行状态,而另一个不是。 Hence pod status is in "NotReady"因此 pod 状态为“NotReady”
  • "1/2" under "Ready" column in kubectl get pods also indicates the same that only container is in ready state out of two. kubectl get pods “Ready”列下的“1/2”也表明只有两个容器处于就绪状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM