Back-off restarting failed container报错

6 篇文章 0 订阅
4 篇文章 0 订阅

我的配置文件中有这样一小段

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”

原来是这样。镜像启动容器后,容器内部没有常驻进程,导致容器启动成功后即退出,从而进行了持续的重启。

只需要给容器加上一个常驻的进程就可以
那么就可以写成

apiVersion: v1
kind: Pod
metadata: 
  name: busybox
  namespace: default
  labels:
    app: busybox
spec: 
  containers:
  - name: busybox
    image: busybox
    command: ["/bin/sh","-ce","sleep 3600"]

在这里插入图片描述

  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值