【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
相关推荐
-小末37 分钟前
使用docker manifest制作本地多架构镜像
docker·容器·多架构镜像
掘金安东尼3 小时前
Amazon Polly :让文字开口说话的云端实践
人工智能·云原生
照物华5 小时前
K8s概念之进程、容器与 Pod 的终极指南
云原生·容器·kubernetes
vvilkim11 小时前
Java主流框架全解析:从企业级开发到云原生
java·运维·云原生
JohnYan17 小时前
工作笔记 - CentOS7环境运行Bun应用
javascript·后端·容器
ezreal_pan17 小时前
Kubernetes 负载均衡现象解析:为何同一批次请求集中于单个 Pod
运维·云原生·k8s·traefik
小猿姐18 小时前
KubeBlocks AI:AI时代的云原生数据库运维探索
数据库·人工智能·云原生·kubeblocks
曼岛_18 小时前
[系统架构设计师]云原生架构设计理论与实践(十四)
云原生·系统架构·系统架构设计师
科大饭桶18 小时前
C++入门自学Day14-- Stack和Queue的自实现(适配器)
c语言·开发语言·数据结构·c++·容器
城管不管20 小时前
Docker核心---数据卷(堵门秘籍)
运维·docker·容器