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

推荐订阅源

Forbes - Security
Forbes - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
L
LangChain Blog
量子位
GbyAI
GbyAI
B
Blog RSS Feed
月光博客
月光博客
人人都是产品经理
人人都是产品经理
腾讯CDC
Recent Announcements
Recent Announcements
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
The Cloudflare Blog
D
Docker
Cyberwarzone
Cyberwarzone
U
Unit 42
NISL@THU
NISL@THU
C
Check Point Blog
B
Blog
大猫的无限游戏
大猫的无限游戏
Cisco Talos Blog
Cisco Talos Blog
Recorded Future
Recorded Future
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
G
GRAHAM CLULEY
Engineering at Meta
Engineering at Meta
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
P
Proofpoint News Feed
F
Fortinet All Blogs
V
V2EX
T
Threat Research - Cisco Blogs
T
Threatpost
S
SegmentFault 最新的问题
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园 - 司徒正美
P
Privacy & Cybersecurity Law Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
TaoSecurity Blog
TaoSecurity Blog
Latest news
Latest news
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Y
Y Combinator Blog
P
Privacy International News Feed
L
Lohrmann on Cybersecurity
AWS News Blog
AWS News Blog
G
Google Developers Blog
美团技术团队

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的探针机制
ike · 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导致程序不可用,但容器并没有检测到挂掉之类的,探针这时候也可以检测到,然后自动重启。

其他#

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

文章#

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