作者:pxrty_635 | 来源:互联网 | 2023-08-27 09:02
原标题:Back-off restarting failed container报错
我的配置文件中有这样一小段
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 ---- ------ ---- ----
------- N文章来源地址15959.htmlormal Scheduled 87s default-www.yii666.comscheduler 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
p文章来源地址15959.htmlulled 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文章来源站点https://www.yii666.com/ “busybox”
原来是这样。镜像启动容器后,容器内部没有常驻进程,www.yii666.com导致容器启动成功后即退出,从而进行了持续的重启。
只需要给容器加上一个常驻的进程就可以
那么就可以写成
apiVersion: v1
kind: Pod
metadata:
name: busybox
namespace: default
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
command: ["/bin/sh","-ce","sleep 3600"]
来源于:Back-off restarting failed container报错