当前位置: 代码网 > 服务器>服务器>Linux > 【K8S】pod无限重启,报错Back-off restarting failed container

【K8S】pod无限重启,报错Back-off restarting failed container

2024年07月28日 Linux 我要评论
Back-off restarting failed container的Warning事件,一般是由于通过指定的镜像启动容器后,容器内部没有常驻进程,导致容器启动成功后即退出,从而进行了持续的重启。**解决方法:**找到对应的deployment,加上如下语句: command: [“/bin/bash”, “-ce”, “tail -f /dev/null”]pod启动后一直重启,并报Back-off restarting failed container。

1. 问题

pod启动后一直重启,并报back-off restarting failed container。

原理: back-off restarting failed container的warning事件,一般是由于通过指定的镜像启动容器后,容器内部没有常驻进程,导致容器启动成功后即退出,从而进行了持续的重启。

2. 解决方案

**解决方法:**找到对应的deployment,加上如下语句: command: [“/bin/bash”, “-ce”, “tail -f /dev/null”]

apiversion: apps/v1
kind: deployment
metadata:
  name: test-file
  namespace: model
  labels:
    appkey: test-file
spec:
  replicas: 1
  selector:
    matchlabels:
      appkey: test-file
  template:
    metadata:
      labels:
        appkey: test-file
    spec:
      containers:
        - name: test-file
          image: xxx:v1
          command: ["/bin/bash", "-ce", "tail -f /dev/null"]
          imagepullpolicy: ifnotpresent
          volumemounts:
          - name: test-file-data
            mountpath: /mnt
      volumes:
        - name: test-file-data
          hostpath: 
            path: /mnt
(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com