为什么带有简单 hello-world 图像的 kubernetes pod 会收到 CrashLoopBackOff 消息 [英] Why is a kubernetes pod with a simple hello-world image getting a CrashLoopBackOff message

查看:19
本文介绍了为什么带有简单 hello-world 图像的 kubernetes pod 会收到 CrashLoopBackOff 消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pod.yml

apiVersion: v1
kind: Pod
metadata:
    name: hello-pod
    labels:
        zone: prod
        version: v1
spec:
    containers:
    - name: hello-ctr
      image: hello-world:latest
      ports:
      - containerPort: 8080

kubectl create -f pod.yml

kubectl get pods
NAME        READY     STATUS             RESTARTS   AGE
hello-pod   0/1       CrashLoopBackOff   5          5m

为什么 CrashLoopBackOff?

推荐答案

在这种情况下,预期的行为是正确的.hello-world 容器旨在打印一些消息,然后在完成后退出.所以这就是为什么你得到 CrashLoopBackOff -

In this case the expected behavior is correct. The hello-world container is meant to print some messages and then exit after completion. So this is why you are getting CrashLoopBackOff -

Kubernetes 运行一个 pod - 里面的容器运行预期的命令然后退出.

Kubernetes runs a pod - the container inside runs the expected commands and then exits.

突然下面没有任何东西在运行 - 所以 pod 再次运行 -> 同样的事情发生并且 restarts 的数量增加了.

Suddenly there is nothing running underneath - so the pod is ran again -> same thing happens and the number of restarts grows.

你可以看到在kubectl describe pod中,Terminated状态是可见的,它的Reason状态是Completed代码>.如果您选择完成后不退出的容器映像,则 pod 将处于运行状态.

You can see that inkubectl describe pod where Terminated state is visible and the Reason for it is status Completed. If you would choose a container image which does not exit after completion the pod would be in running state.

这篇关于为什么带有简单 hello-world 图像的 kubernetes pod 会收到 CrashLoopBackOff 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆