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
本文作者:little小新
本文链接:https://www.cnblogs.com/littlecc/p/17639004.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步