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
发表评论