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

kubernetes第五天

1.容器的健康检查Probe(探针)之readinessProbe就绪探针

  1.exec方式检查

#通过rc资源创建了三个pod,然后使用services资源,对外提供三个pod的容器的访问入口。
apiVersion: v1
kind: ReplicationController
metadata:name: web-rc-readlineprobe
spec:replicas: 3selector:name: lxczuoyong: webtemplate:metadata:labels:name: lxczuoyong: webspec:zuoyong: webzuoyong: webcontainers:- name: nginximage: harbor.lxcedu.com/base-img/nginx:1.14.2command:- /bin/sh- -c- "touch /tmp/healthy; sleep 5; rm -f /tmp/healthy; sleep 60"#容器的就绪性检查,如果执行command命令成功则,标记为未就绪状态readinessProbe:exec:command:- cat- /tmp/healthyfailureThreshold: 3initialDelaySeconds: 15periodSeconds: 1successThreshold: 1timeoutSeconds: 1
---
apiVersion: v1
kind: Service
metadata:name: web-readinessprobenamespace: default
spec:selector:name: lxczuoyong: webtype: ClusterIPports:- port: 80targetPort: 80protocol: TCP

readinessProbe探针,如果检查不符合条件,pod的状态会变为未就绪,如图READY为0/1

通过查询ep和svc也可以看出三个pod处于未就绪状态,所以也不会加入web-readinessprobe中,所以ep资源就为空,kubectl describe ep web-readinessprobe可以看到三个节点都为未就绪状态。

2.httpGet方式检查

把exec检查方法的无关command删除,再把里面exec换成下面代码就变成httpGet检查

httpGet:# 指定访问的端口号port: 80# 检测指定的访问路径path: /index.html

启动之后发现pod的容器16秒到17秒状态由未就绪变为就绪,说明:未检查时容器处于未就绪状态。

删除容器的index.html文件,

kubectl exec web-rc-readlineprobe-httpget-hncm4 -- rm  /usr/share/nginx/html/index.html

发现对应的pods的容器处于未就绪状态。

http://www.lryc.cn/news/516649.html

相关文章:

  • 扩散模型论文概述(三):Stability AI系列工作【学习笔记】
  • JVM调优,参数在哪里设置的?
  • 2024年最新Stable Diffusion 新手入门教程,安装使用及模型下载
  • Ubuntu 20.04安装gcc
  • IT运维的365天--024 闲置路由器关闭了dhcp,如何知道它的IP是啥
  • kaggle竞赛:纽约出租车行程时间NYC Taxi Trip Duration
  • Freemarker模板进行判空
  • C++ const关键字(八股总结)
  • Linux 清楚历史命令
  • 服务器双网卡NCCL通过交换机通信
  • Redis哨兵(sentinel)
  • 小白学Pytorch
  • ros2笔记-2.5.3 多线程与回调函数
  • 第5章:Go语言错误处理和异常
  • 题库刷题知识点总结
  • GraphRAG:LLM之Graphrag接入milvus
  • adb使用及常用命令
  • omnipeek分析beacon帧
  • Java数组问题
  • salesforce 可以为同一个简档的同一个 recordtype 的对象设置多种页面布局吗
  • 使用vue项目中,使用webpack模板和直接用vue.config来配置相关插件 区别是什么,具体有哪些提现呢
  • 五、包图
  • 关于重构一点简单想法
  • kafka使用以及基于zookeeper集群搭建集群环境
  • GAN对抗生成网络(二)——算法及Python实现
  • 并发线程(21)——线程池
  • 基于32单片机的智能语音家居
  • VScode怎么重启
  • 分析服务器 systemctl 启动gozero项目报错的解决方案
  • 大模型LLM-Prompt-OPTIMAL