【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
相关推荐
福大大架构师每日一题8 小时前
22.1 k8s不同role级别的服务发现
容器·kubernetes·服务发现
莹雨潇潇8 小时前
Docker 快速入门(Ubuntu版)
java·前端·docker·容器
weixin_453965009 小时前
[单master节点k8s部署]30.ceph分布式存储(一)
分布式·ceph·kubernetes
weixin_453965009 小时前
[单master节点k8s部署]32.ceph分布式存储(三)
分布式·ceph·kubernetes
tangdou3690986559 小时前
1分钟搞懂K8S中的NodeSelector
云原生·容器·kubernetes
Lansonli10 小时前
云原生(四十一) | 阿里云ECS服务器介绍
服务器·阿里云·云原生
Dylanioucn11 小时前
【分布式微服务云原生】掌握分布式缓存:Redis与Memcached的深入解析与实战指南
分布式·缓存·云原生
tangdou36909865512 小时前
Docker系列-5种方案超详细讲解docker数据存储持久化(volume,bind mounts,NFS等)
docker·容器
later_rql12 小时前
k8s-集群部署1
云原生·容器·kubernetes
weixin_4539650015 小时前
[单master节点k8s部署]31.ceph分布式存储(二)
分布式·ceph·kubernetes