18、k8s-pod的生命周期-重启策略(Always、OnFailure、Nerver)
实例:容器如果探测、获取不到http地址的话、让容器不再尝试重启(Nerver)
1、新建yaml文件:vim pod-restartpolicy.yaml
==========================
apiVersion: v1
kind: Pod
metadata:
name: pod-restartpolicy
namespace: dev
spec:
containers:
- name: nginx
image: nginx:1.17.1
ports:
- name: nginx-port
containerPort: 80
livenessProbe:
httpGet:
scheme: HTTP
port: 80
path: /hello
restartPolicy: Never #设置重启策略为nerver 与containers同级
===================================
2、执行文件创建pod:kubectl create -f pod-restartpolicy.yaml
3、动态查看pod状态:kubectl get pod pod-restartpolicy -ndev -w
4、kubectl describe pod pod-restartpolicy -ndev