Pod存活性探测
发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,Pod存活性探测:用于判断容器是否处理"运行"状态,如果检测未通过,kubelet将会终止容器,根据启动策略(restartPolicy)决定是否重启,如果未定义容器默认为"Success"。存活性探
千家信息网最后更新 2025年02月01日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安全错误
数据库的锁怎样保障安全
服务器是如何提供网络信号的
golang 数据库查询
盈科软件开发
昭通辰庆互联网科技有限公司
南京溧水软件开发公司电话
合肥软件开发的培训
软件测试常用数据库下载
监控技术网络安全
hyp服务器国际服停服
网络安全大赛喜获
2k20服务器联网怎么样
移动光猫服务器可以选择吗
党组会议研究网络安全工作
学java好还是网络安全好
软件开发困难的原因
y数据库建设
服务器无法请求http协议
乐思真做网络安全怎么写
南方电网的网络安全
云锁win服务器管理是什么
数据库模式的通俗理解
网络技术员 出路
计算机网络技术与数学
小学生网络安全知识选择题
刀片服务器架
校园网络安全教育心得
杭州家杰网络技术有限公司
数据库字段为空值怎么设置
平安建设网络安全工作情况报告
对计算机网络技术同学的建议