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

推荐订阅源

AWS News Blog
AWS News Blog
T
Tenable Blog
Project Zero
Project Zero
T
The Exploit Database - CXSecurity.com
L
LINUX DO - 热门话题
T
Threat Research - Cisco Blogs
T
Threatpost
Security Latest
Security Latest
C
Cisco Blogs
L
Lohrmann on Cybersecurity
S
Security @ Cisco Blogs
Google Online Security Blog
Google Online Security Blog
NISL@THU
NISL@THU
AI
AI
V
Vulnerabilities – Threatpost
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Last Watchdog
The Last Watchdog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
H
Hackread – Cybersecurity News, Data Breaches, AI and More
H
Hacker News: Front Page
U
Unit 42
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MyScale Blog
MyScale Blog
O
OpenAI News
Scott Helme
Scott Helme
V2EX - 技术
V2EX - 技术
P
Proofpoint News Feed
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cyberwarzone
Cyberwarzone
博客园 - 【当耐特】
H
Heimdal Security Blog
S
Schneier on Security
阮一峰的网络日志
阮一峰的网络日志
Help Net Security
Help Net Security
D
DataBreaches.Net
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
TaoSecurity Blog
TaoSecurity Blog
K
Kaspersky official blog
N
News and Events Feed by Topic
WordPress大学
WordPress大学
P
Palo Alto Networks 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导致程序不可用,但容器并没有检测到挂掉之类的,探针这时候也可以检测到,然后自动重启。

其他#

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

文章#

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