当前位置: 首页 > news >正文

readinessProbe探针三种实现方式

exec探测方式

[root@master231 pods]# cat 23-pods-readinessprobe-livenessProbe-exec.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:name: deploy-readinessprobe
spec:replicas: 3selector:matchLabels:apps: v1template:metadata:labels:apps: v1spec:containers:- image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1name: c1command: - /bin/sh- -c- touch /tmp/oldboyedu-linux-healthy; sleep 35; rm -f /tmp/oldboyedu-linux-healthy; sleep 600livenessProbe:exec:command:- cat- /tmp/oldboyedu-linux-healthyfailureThreshold: 3initialDelaySeconds: 65periodSeconds: 1successThreshold: 1timeoutSeconds: 1# 可用性检查,周期性检查服务是否可用,从而判断容器是否就绪.readinessProbe:# 使用exec的方式去做健康检查exec:# 自定义检查的命令command:- cat- /tmp/oldboyedu-linux-healthyfailureThreshold: 3initialDelaySeconds: 5periodSeconds: 1successThreshold: 1timeoutSeconds: 1---apiVersion: v1
kind: Service
metadata:name: oldboyedu-readinessprobe-exec
spec:selector:apps: v1ports:- port: 80targetPort: 80protocol: TCP

httpGet探测方式

[root@master231 pods]# cat 24-pods-readinessProbe-httpGet.yaml 
apiVersion: v1
kind: Pod
metadata:name: readinessprobe-httpget-001labels:apps: v2
spec:containers:- image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v2name: c1command: - /bin/sh- -c- touch /tmp/oldboyedu-linux-healthy; sleep 5; rm -f /tmp/oldboyedu-linux-healthy; sleep 600livenessProbe:exec:command:- cat- /tmp/oldboyedu-linux-healthyfailureThreshold: 3initialDelaySeconds: 90periodSeconds: 1successThreshold: 1timeoutSeconds: 1# 可用性检查,周期性检查服务是否可用,从而判断容器是否就绪.readinessProbe:# 使用httpGet的方式去做健康检查httpGet:# 指定访问的端口号port: 80path: /index.htmlfailureThreshold: 3initialDelaySeconds: 15periodSeconds: 1successThreshold: 1timeoutSeconds: 1---apiVersion: v1
kind: Service
metadata:name: readinessprobe-httpget
spec:selector:apps: v2ports:- port: 80targetPort: 80protocol: TCPclusterIP: 10.200.0.11

tcpSocket探测方式

[root@master231 pods]# cat 25-pods-readinessProbe-tcpSocket.yaml 
apiVersion: v1
kind: Pod
metadata:name: readinessprobe-tcpsocket-001labels:apps: v3
spec:containers:- image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v3name: c1command: - /bin/sh- -c- touch /tmp/oldboyedu-linux-healthy; sleep 15; rm -f /tmp/oldboyedu-linux-healthy; nginx -g "daemon off;"livenessProbe:exec:command:- cat- /tmp/oldboyedu-linux-healthyfailureThreshold: 3initialDelaySeconds: 60periodSeconds: 1successThreshold: 1timeoutSeconds: 1# 可用性检查,周期性检查服务是否可用,从而判断容器是否就绪.readinessProbe:# 使用tcpSocket的方式去做健康检查tcpSocket:# 探测80端口是否存活port: 80failureThreshold: 3initialDelaySeconds: 0periodSeconds: 1successThreshold: 1timeoutSeconds: 1---apiVersion: v1
kind: Service
metadata:name: readinessprobe-tcpsocket
spec:selector:apps: v3ports:- port: 80targetPort: 80clusterIP: 10.200.0.22

测试方式:

[root@master231 ~]# while true;do curl 10.200.0.22;sleep 0.5;done
http://www.jsqmd.com/news/555204/

相关文章:

  • GTE中文嵌入模型部署案例:中文新闻聚合平台热点事件发现系统
  • 3步解锁AI视频增强:让低清视频秒变4K的开源方案
  • 一丹一世界FLUX.1部署教程:防火墙开放7861端口+nginx反向代理+HTTPS安全加固
  • 告别Arduino IDE!用VS Code+PlatformIO高效开发ESP32-S3视觉项目(含摄像头测试)
  • DJI Cloud API 停更启示录:从开源Demo到企业级上云的战略转向
  • claude code 相关学习
  • 北斗网格码实战:从编码原理到Java实现(非极地区域)
  • OpenClaw配置备份:nanobot环境迁移指南
  • 保姆级教程:在MounRiver Studio上为CH32V307配置FreeRTOS与LwIP网络栈
  • 搞懂 SAPUI5 Application Index:为什么你的 Fiori 应用改完了,系统却像没看见一样
  • Seelen UI完全自定义桌面环境:从零开始打造你的Windows个性化工作空间
  • LongCat-Image-Edit与QT结合:开发跨平台动物图片编辑器
  • OpenClaw多模态扩展:百川2-13B量化模型+OCR技能实战
  • 卡方检验实战:用Python快速验证老虎机是否被动手脚(附完整代码)
  • 如何用CC Switch实现多AI服务统一管理与高可用架构
  • Ubuntu 22.04上Ollama GPU加速避坑全记录:从驱动到容器,一次搞定
  • PDF-Parser-1.0在企业级应用中的性能调优
  • Loop:重新定义macOS窗口管理的交互革命
  • 【技术解析】DNBSEQ如何通过双Barcode与纳米球阵列近乎消除Index Hopping
  • 从万用表到精密测量:拆解双积分ADC如何成为低速高精度模数转换的‘常青树’
  • PowerPaint-V1 Gradio与VSCode集成开发:图像修复插件开发指南
  • 万物识别镜像实战案例:如何用MySQL管理上万张图片识别结果?
  • 当孩子情绪管理困难时,如何帮助他们不会社交?
  • Android OTA升级踩坑实录:UpdateEngine魔数校验失败与OverlayFS冲突的完整解决流程
  • Windows 7 SP2终极革新方案:让经典系统完美适配现代硬件环境的智能架构
  • GLM-OCR在办公场景的应用:快速将合同、票据图片转为可编辑文本
  • SenseVoice语音识别镜像深度体验:自动语言检测+高效推理,实测效果惊艳
  • 老旧Mac焕新指南:用OpenCore让你的设备支持Monterey系统
  • 别再死记硬背了!用‘神经元工作原理’理解你背单词为什么总忘
  • 盘点2026年好用的新全自动分切机,瑞安市合创机械制造值得推荐 - 工业品网