我的配置文件中有这样一小段
apiVersion: v1
kind: Pod
metadata:
name: busybox
namespace: default
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
来测试配置清单是否可用。
出现错误时:
kubectl logs busybox -p
这时候因为没有访问 是看不到日志的
kubectl describe pod busybox
看到了问题所在:
Events: Type Reason Age From
Message ---- ------ ---- ----
------- Normal Scheduled 87s default-scheduler Successfully assigned default/busybox to node2 Normal Pulled
71s kubelet Successfully pulled image
“busybox” in 15.824134554s Normal Pulled 69s
kubelet Successfully pulled image “busybox” in 1.345001397s
Normal Pulled 36s kubelet Successfully
pulled image “busybox” in 15.738609779s Normal Created 36s (x3
over 71s) kubelet Created container busybox Normal
Started 36s (x3 over 71s) kubelet Started container
busybox Warning BackOff 22s (x4 over 68s) kubelet
Back-off restarting failed container Normal Pulling 11s (x4
over 87s) kubelet Pulling image “busybox”
原来是这样。镜像启动容器后,容器内部没有常驻进程,导致容器启动成功后即退出,从而进行了持续的重启。
只需要给容器加上一个常驻的进程就可以
那么就可以写成文章来源:https://www.toymoban.com/news/detail-816802.html
apiVersion: v1
kind: Pod
metadata:
name: busybox
namespace: default
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
command: ["/bin/sh","-ce","sleep 3600"]
文章来源地址https://www.toymoban.com/news/detail-816802.html
到了这里,关于Back-off restarting failed container报错的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!