gpt4 book ai didi

kubernetes - 如何定义 liveness 命令

转载 作者:行者123 更新时间:2023-12-04 06:31:41 24 4
gpt4 key购买 nike

下面的 livenessProbe(从 an example 中提取)运行良好。

livenessProbe:
exec:
command:
- cat
- /tmp/healthy

但是,我的 livenessProbe 不起作用。(pod 不断重新启动)。
YAML在下面
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness-test
name: liveness
spec:
containers:
- name: liveness
args:
- /bin/bash
- -c
- /home/my_home/run_myprogram.sh; sleep 20
image: liveness:v0.6
securityContext:
privileged: true
livenessProbe:
exec:
command:
- /home/my_home/check.sh
initialDelaySeconds: 10
periodSeconds: 5

/home/my_home/check.sh(在运行的进程数为1或0时重启pod)在下面,这是预先测试过的。
#!/bin/sh
if [ $(ps -ef | grep -v grep | grep my-program | wc -l) -lt 2 ]; then
exit 1
else
exit 0
fi

最佳答案

此问题与Golang Command API有关.
我改变了 livenessProbe 如下

livenessProbe:
exec:
command:
- /bin/sh
- -c
- /home/test/check.sh

关于kubernetes - 如何定义 liveness 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45647825/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com