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

原文链接:https://blog.csdn.net/u012856866/article/details/138701701

posted @ 2024-09-23 16:11  羊脂玉净瓶  阅读(163)  评论(0)    收藏  举报