【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
相关推荐
一殊酒33 分钟前
【Docker】快速入门指南
运维·docker·容器
**蓝桉**40 分钟前
prometheus监控docker容器(Rocky9)
docker·容器·prometheus
linux修理工41 分钟前
EasyVoice 项目部署与使用指南(开源文字互转声音)
云原生·eureka
lpruoyu42 分钟前
【云原生】Helm应用商店
云原生
专注_每天进步一点点2 小时前
serverless的slb
云原生·serverless
Mr_Chenph2 小时前
备份Docker
运维·docker·容器
http阿拉丁神猫2 小时前
kubernetes知识点汇总19~24
云原生·容器·kubernetes
IT界的老黄牛2 小时前
RocketMQ 5.x 集群部署实战:3 台机器搞定 2 主 2 从,Docker Host 模式一把梭
docker·容器·rocketmq
lpruoyu3 小时前
【云原生】kustomize_常见的部署方式
云原生
春日见3 小时前
UniAD的逻辑,与传统自动驾驶的差异
人工智能·windows·git·机器学习·docker·容器·自动驾驶