K8s:如果 pod 变得不健康并重新启动,为什么没有简单的方法来获取通知?
K8s: why is there no easy way to get notifications if a pod becomes unhealthy and is restarted?
如果 pod 变得不健康并重新启动,为什么没有简单的方法来获取通知?
对我来说,这表明我不应该关心 pod 是否重新启动,但为什么不呢?
如果 pod/container 由于某种原因崩溃,Kubernetes 应该提供 reliability/availability 它将在集群中的其他地方启动。话虽如此,您可能需要警告和警报(如果您的 pod 进入 Crashloopbackoff
.
尽管您可以编写自己的工具,但您可以监视集群中的特定事件,然后 alert/warn 使用其中一些工具:
- kubewatch
- kube-slack(松弛工具)。
- 最流行的K8s监控工具:prometheus.
- 像Sysdig这样的付费工具。
将 Pods 视为短暂的实体 - 它们可以存在于不同的节点中,它们可以崩溃,它们可以重新开始...
Kubernetes 负责处理 lifecycle of a pod. Your job is to tell it where to run (affinity rules) and how to tell if a pod if healthy.
监控 pod 崩溃的方法有很多种。例如 - prometheus 与 Kubernetes 有很好的集成。
I wrote an open source tool to do this called Robusta。 (是的,它是以咖啡命名的。)
您可以将通知发送到多个目的地 - 这是 Slack 的屏幕截图。
在幕后,我们使用自己的 Kubewatch 分支来跟踪 APIServer 事件,但我们正在添加多种功能,例如获取日志。
您在 YAML 中定义触发器和操作:
- triggers:
- on_pod_update: {}
actions:
- restart_loop_reporter:
restart_reason: CrashLoopBackOff
- image_pull_backoff_reporter:
rate_limit: 3600
每个动作都使用 Python 函数定义,但您通常不需要自己编写它们,因为我们有 50 多个内置动作。 (查看一些示例,here。)
如果 pod 变得不健康并重新启动,为什么没有简单的方法来获取通知?
对我来说,这表明我不应该关心 pod 是否重新启动,但为什么不呢?
如果 pod/container 由于某种原因崩溃,Kubernetes 应该提供 reliability/availability 它将在集群中的其他地方启动。话虽如此,您可能需要警告和警报(如果您的 pod 进入 Crashloopbackoff
.
尽管您可以编写自己的工具,但您可以监视集群中的特定事件,然后 alert/warn 使用其中一些工具:
- kubewatch
- kube-slack(松弛工具)。
- 最流行的K8s监控工具:prometheus.
- 像Sysdig这样的付费工具。
将 Pods 视为短暂的实体 - 它们可以存在于不同的节点中,它们可以崩溃,它们可以重新开始...
Kubernetes 负责处理 lifecycle of a pod. Your job is to tell it where to run (affinity rules) and how to tell if a pod if healthy.
监控 pod 崩溃的方法有很多种。例如 - prometheus 与 Kubernetes 有很好的集成。
I wrote an open source tool to do this called Robusta。 (是的,它是以咖啡命名的。)
您可以将通知发送到多个目的地 - 这是 Slack 的屏幕截图。
在幕后,我们使用自己的 Kubewatch 分支来跟踪 APIServer 事件,但我们正在添加多种功能,例如获取日志。
您在 YAML 中定义触发器和操作:
- triggers:
- on_pod_update: {}
actions:
- restart_loop_reporter:
restart_reason: CrashLoopBackOff
- image_pull_backoff_reporter:
rate_limit: 3600
每个动作都使用 Python 函数定义,但您通常不需要自己编写它们,因为我们有 50 多个内置动作。 (查看一些示例,here。)