pod报错"Back-off restarting failed container"解决办法
现象
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 2m48s default-scheduler Successfully assigned default/test to master1
Normal Pulled 70s (x5 over 2m46s) kubelet Container image "ubuntu:18.04" already present on machine
Normal Created 70s (x5 over 2m46s) kubelet Created container ubuntu1
Normal Started 70s (x5 over 2m46s) kubelet Started container ubuntu1
Warning BackOff 58s (x10 over 2m44s) kubelet Back-off restarting failed container
解决:
在deployment申明镜像的后面加上命令
command: [ “/bin/bash”, “-ce”, “tail -f /dev/null” ]
root@master1:~/syq# vim admin-test.yaml
apiVersion: v1
kind: Pod
metadata:
name: test
spec:
containers:
- image: ubuntu:18.04
name: ubuntu1
command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]
securityContext:
capabilities:
add: ["CAP_SYS_ADMIN"]
volumeMounts:
- name: app-volume
mountPath: /cdk
volumes:
- name: app-volume
hostPath:
path: /root/cdk