【K8S】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"]

python 复制代码
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
相关推荐
wuxingge32 分钟前
k8s部署xxl-job
容器·kubernetes
没有bug.的程序员2 小时前
微服务基础设施清单:必须、应该、可以、无需的四级分类指南
java·jvm·微服务·云原生·容器·架构
百以国际食品有限公司2 小时前
奶茶原料珍珠粉圆品质保证
云原生
Lethehong3 小时前
【探索实战】Kurator分布式云原生平台快速上手与实战指南
分布式·云原生
百以国际食品有限公司3 小时前
奶茶原料珍珠粉圆供应商
云原生
Lethehong4 小时前
【探索实战】Kurator分布式云原生平台全栈实践指南:从入门到企业级落地
分布式·云原生
weixin_462446234 小时前
【实战原创】Docker 清理指南:以 Coze Studio 为例的资源保留与清理实践(非万能方案)
docker·容器·eureka
hkNaruto4 小时前
【docker】docker exec -it 报错 open /dev/pts/0: operation not permitted
运维·docker·容器
一个想打拳的程序员4 小时前
无需复杂配置!用%20docker-webtop%20打造跨设备通用%20Linux%20桌面,加载cpolar远程访问就这么简单
java·人工智能·docker·容器
Wang's Blog4 小时前
RabbitMQ: 解析Kubernetes原理与高可用集群部署实践
分布式·kubernetes·rabbitmq