Pod存活性探测
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,Pod存活性探测:用于判断容器是否处理"运行"状态,如果检测未通过,kubelet将会终止容器,根据启动策略(restartPolicy)决定是否重启,如果未定义容器默认为"Success"。存活性探
千家信息网最后更新 2025年12月02日Pod存活性探测
Pod存活性探测:用于判断容器是否处理"运行"状态,如果检测未通过,kubelet将会终止容器,根据启动策略(restartPolicy)决定是否重启,如果未定义容器默认为"Success"。存活性探测支持的方法有三种:ExecAction,TCPSocketAction,HTTPGetAction。
1.使用exec探测文件存在
[root@k8s01 yaml]# kubectl explain pods.spec.containers.livenessProbe
[root@k8s01 yaml]# vim execaction.yaml
apiVersion: v1kind: Podmetadata: labels: test: exec-execaction name: execactionspec: containers: - name: execaction image: busybox:latest args: ["/bin/sh","-c","touch /tmp/test.txt"] --容器启动后创建test.txt文件 livenessProbe: exec: command: ["test","-e","/tmp/test.txt"] --检查test.txt文件,如果存在Pod正常启动,如果不存在Pod创建不成功
[root@k8s01 yaml]# kubectl apply -f execaction.yaml
pod/execaction created
[root@k8s01 yaml]#
2.使用tcp协议探测端口
[root@k8s01 yaml]# vim tcpaction.yaml
apiVersion: v1kind: Podmetadata: labels: test: tcp-execaction name: tcpactionspec: containers: - name: tcpaction image: nginx:latest ports: - name: http containerPort: 80 --暴露80端口 livenessProbe: tcpSocket: --使用tcp探测 port: http --这里可以写协议或者端口,http默认为80端口
[root@k8s01 yaml]# kubectl apply -f tcpaction.yaml
pod/tcpaction created
[root@k8s01 yaml]#
3.使用http协议探测服务
[root@k8s01 yaml]# vim httpaction.yaml
apiVersion: v1kind: Podmetadata: labels: test: http-execaction name: httpactionspec: containers: - name: httpaction image: nginx:latest ports: - name: http containerPort: 80 lifecycle: postStart: --容器启动之前启动以下命令 exec: command: ["/bin/sh","-c","echo 123 > /usr/share/nginx/html/test.html"] livenessProbe: httpGet: path: /test.html --探测nginx是否正常访问test.html页面 port: http
[root@k8s01 yaml]# kubectl apply -f httpaction.yaml
pod/httpaction created
[root@k8s01 yaml]#
探测
容器
端口
文件
成功
命令
方法
状态
策略
页面
处理
支持
服务
检查
检测
运行
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
常宁市软件开发培训
网络安全海报手绘素材
云服务器对公司有什么好处
浙江台州塑胶模具erp软件开发
长沙ibm服务器代理
山东多线服务器云空间
国内计算机网络安全事件
文献检索的中文英文数据库有哪些
数据库插入失败错误代码0001
软件开发用到的日语
新人 软件开发 培训内容
小学班级网络安全方案
一站到底网络安全
服务器生成页面链接
深圳学软件开发那里好
网络安全专业包括计算机专业吗
家禽资源数据库
古墓丽影崛起怎么开服务器
腾讯云域名上传到服务器
默纳克服务器调试完如何退出
云服务器管理器怎么打开
个人软件开发开票税点
现代学徒制 软件开发
宝山区高科技软件开发排行
软件开发最后会有什么工作
世嘉转为游戏软件开发商
服务器怎么复制应用
我的世界1.17服务器如何开
资深软件开发工程师
加拿大服务器咋样