kubernetes - 后台进程的 LivenessProbe 命令
问题描述
什么是适合livenessProbe
后台进程的 Kubernetes 命令?
我们有一个 NodeJS 进程,它使用 SQS 队列中的消息。由于它是一项后台作业,我们不公开任何 HTTP 端点,因此活性命令似乎是进行活性检查的更合适的方式。一个“足够好”的命令设置实际上会检查进程是否处于活动状态并正常运行?NodeJS 进程是否应该触摸一个文件以更新其编辑时间并且活性检查验证这一点?我在网上看到的示例似乎与实际过程脱节,例如他们检查文件是否存在。
解决方案
You could use liveness using exec
command.
Here is an example:
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: liveness-exec
spec:
containers:
- name: liveness
image: k8s.gcr.io/busybox
args:
- /bin/sh
- -c
- touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5
To perform a probe, the kubelet executes the command cat /tmp/healthy in the target container. If the command succeeds, it returns 0, and the kubelet considers the container to be alive and healthy. If the command returns a non-zero value, the kubelet kills the container and restarts it.
推荐阅读
- amazon-web-services - 使用 AWS Amplify 创建 SNS 终端节点。怎么做?
- sharepoint - 如何以编程方式获取租户中当前用户的“最近访问的共享点站点”?
- google-tag-manager - 如何从标签谷歌标签管理器获取谷歌标签 ID
- html - 如何使用 HTML 渲染图像,使用 Flutter 创建 iOS-App 的 CSS?
- azure - 为什么不同的 Microsoft Graph API 返回不同的数据
- javascript - jquery 验证无法正常工作
- git - 从 TFS 克隆所有远程存储库
- node.js - Sequelize 似乎上限为 30 个模型
- node.js - 猫鼬 findByIdAndRemove() 奇怪的行为
- javascript - 将具有类(及其基础元素)的现有 div 元素添加到 div