惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

SecWiki News
SecWiki News
I
InfoQ
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
博客园 - Franky
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
量子位
博客园_首页
罗磊的独立博客
V
V2EX
李成银的技术随笔
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
True Tiger Recordings
Vercel News
Vercel News
Cyberwarzone
Cyberwarzone
Cisco Talos Blog
Cisco Talos Blog
F
Fox-IT International blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
M
Microsoft Research Blog - Microsoft Research
Know Your Adversary
Know Your Adversary
爱范儿
爱范儿
The Register - Security
The Register - Security
G
Google Developers Blog
The Hacker News
The Hacker News
Malwarebytes
Malwarebytes
S
Securelist
博客园 - 三生石上(FineUI控件)
Jina AI
Jina AI
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
S
SegmentFault 最新的问题
博客园 - 叶小钗
F
Fortinet All Blogs
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
博客园 - 聂微东
T
Threatpost
博客园 - 【当耐特】
D
Docker
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
V
Visual Studio Blog
C
Cisco Blogs
IT之家
IT之家
S
Security Archives - TechRepublic
Latest news
Latest news
阮一峰的网络日志
阮一峰的网络日志

ike‘s blog

mac软件推荐 用Siri来控制Windows电脑开机关机吧 clickhouse的一些优化建议和工具 2023sumppary 记录一下我的第一个网页游戏Mazeball 如何使用Clickhouse的索引 如何从zookeeper切换为clickhouse—keeper cloki分布式查询和clickhouse副本存储 使用ilogtail+cloki+clickhouse来做日志系统吧 clickhouse集群部署指南 快速安装部署clickhouse和cloki 快速部署thanos架构 如何使用go的jwt 如何修改git commit记录 业务容器化需要注意的一些地方 游戏企划 Prometheus Metrics精简优化2 来在线听音乐吧 Chatgpt的API入门 简单搭建国内也可以使用的chatgpt Prometheus Metrics精简优化 本地部署chatAI【chatglm】 AI绘画工具webui简单入门 之 高清化 写在地下城邂逅Ⅳ·灾厄篇·完结之后 如何部署gitalk作为评论系统 AI绘画工具webui简单入门 之 工具安装 grafanadb迁移到mysql kubectl常用命令 开始写博客啦 隐私政策URL Markdown Example Include Video in the Posts Markdown Extended Features Simple Guides for Fuwari Golang net/http & HTTP Serve 源码分析
Kubernetes的探针机制
2023-03-28 · via ike‘s blog

演示#

k8s里探针有三种:存活(livenessProbe)、就绪(readinessProbe)和启动(startupProbe)探针

直接演示一下代码吧

....省略其他....
      containers:
        - name: nginx
          image: registry.k8s.io/busybox:v1
          imagePullPolicy: IfNotPresent
          readinessProbe:
            httpGet:
              port: 1111
              path: /metrics/prometheus
            initialDelaySeconds: 60
            successThreshold: 1
            failureThreshold: 3
            timeoutSeconds: 5
          startupProbe:
            httpGet:
              port: 1111
              path: /metrics/prometheus
            initialDelaySeconds: 60
            successThreshold: 1
            failureThreshold: 3
            timeoutSeconds: 5
          livenessProbe:
            httpGet:
              port: 1111
              path: /metrics/prometheus
            initialDelaySeconds: 60
            successThreshold: 1
            failureThreshold: 3
            timeoutSeconds: 5
          resources:
            requests:
              memory: 1024Mi
            limits:
              memory: 2048Mi
....省略其他...

解释#

readinessProbe: 用于确定容器是否已准备好接收网络流量。

当探针发现容器已经准备就绪时,Kubernetes 将开始将流量引导到容器中。 使用 HTTP GET 方法检查容器的 /metrics/prometheus 路径是否可用,如果容器返回状态码 200,则认为容器已准备好接收流量。

initialDelaySeconds 表示在容器启动后多少秒后开始检查。 successThreshold 表示成功的最小连续计数。 failureThreshold 表示失败的最小连续计数。 timeoutSeconds 表示检查超时的秒数。

startupProbe: 用于确定容器是否正在启动中。

当探针发现容器正在启动时,Kubernetes 将等待一段时间,以允许容器完成启动过程,然后再检查容器是否已准备就绪。

initialDelaySeconds、successThreshold、failureThreshold 和 timeoutSeconds 参数的含义与 readinessProbe 中的相同。

livenessProbe: 用于确定容器是否正在运行。

当探针发现容器已停止运行时,Kubernetes 将自动重新启动容器。

initialDelaySeconds、successThreshold、failureThreshold 和 timeoutSeconds 参数的含义与 readinessProbe 中的相同。

使用场景#

一般更新业务容器的时候,不加探针的话容器只要能正常启动,原先的容器就会被kill掉,但其实这个时候新的业务容器还没完全起来,这时候就会出现空挡,导致业务不可用,如果加上了探针,只有当新的容器业务完全起来了后,可以检测到监控指标了,才会把旧的kill掉,这样就可以无缝的滚动更新。而且有时候应用可能卡死了,内部出现一些error导致程序不可用,但容器并没有检测到挂掉之类的,探针这时候也可以检测到,然后自动重启。

其他#

一般业务上云,要对业务的日志,监控,以及探针都需要添加,已确保业务上线后可以充分检测到运行情况,方便运维和开发定位和发现问题。

文章#

推荐可以看看官方的文档 配置存活、就绪和启动探针