2017-08-12 66 views
3

下面的livenessProbe(從an example中提取)運行良好。如何定義活躍命令

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

但是,我的livenessProbe沒有工作(莢不斷重新啓動)。 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)低於,這是預測試。

#!/bin/sh 
if [ $(ps -ef | grep -v grep | grep my-program | wc -l) -lt 2 ]; then 
    exit 1 
else 
    exit 0 
fi 

回答

3

此問題與Golang Command API有關。 我改變了活力探針如下

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