0

什么是适合livenessProbe后台进程的 Kubernetes 命令?

我们有一个 NodeJS 进程,它使用 SQS 队列中的消息。由于它是一项后台作业,我们不公开任何 HTTP 端点,因此活性命令似乎是进行活性检查的更合适的方式。一个“足够好”的命令设置实际上会检查进程是否处于活动状态并正常运行?NodeJS 进程是否应该触摸一个文件以更新其编辑时间并且活性检查验证这一点?我在网上看到的示例似乎与实际过程脱节,例如他们检查文件是否存在。

4

1 回答 1

0

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.

于 2020-11-16T00:10:05.267 回答