【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”]
apiVersion: apps/v1
kind: Deployment
metadata:name: test-filenamespace: modellabels:appkey: test-file
spec:replicas: 1selector:matchLabels:appkey: test-filetemplate:metadata:labels:appkey: test-filespec:containers:- name: test-fileimage: xxx:v1command: ["/bin/bash", "-ce", "tail -f /dev/null"]imagePullPolicy: IfNotPresentvolumeMounts:- name: test-file-datamountPath: /mntvolumes:- name: test-file-datahostPath: path: /mnt