活力探针获得定时

时间:2018-10-29 15:05:56

标签: jenkins kubernetes google-compute-engine google-kubernetes-engine

我正在使用Jenkins和Kubernetes来执行此操作。

由于我的loadBalancer需要一个健康的吊舱,因此必须将livenessProbe添加到吊舱中。

我对广告连播的配置:

apiVersion: v1
kind: Pod
metadata:
labels:
  component: ci
spec:
  # Use service account that can deploy to all namespaces
  serviceAccountName: default
  # Use the persisnte volume
  containers:
  - name: gcloud
    image: gcr.io/cloud-builders/gcloud
    command:
    - cat
    tty: true
  - name: kubectl
    image: gcr.io/cloud-builders/kubectl
    command:
    - cat
    tty: true
  - 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

发生的问题是,当我想部署代码(通过CD在Jenkins上)时,就碰到了

  

/ tmp / healthy;

命令,它超时。

我得到的错误响应如下:

java.io.IOException: Failed to execute shell script inside container [kubectl] of pod [wobbl-mobile-label-qcd6x-13mtj]. Timed out waiting for the container to become ready!

当我输入 kubectl获取事件时 我得到以下回应:

Liveness probe failed: cat: can't open '/tmp/healthy': No such file or directory

关于如何解决此问题的任何提示?

我已经读过这个documentation的生动性,我从那里开始进行配置。

1 个答案:

答案 0 :(得分:2)

从您所引用的链接可以看出。该示例旨在帮助您了解活动探针的工作原理。我来自以下link

的示例

他们在

之后有意删除了/ tmp / healthy文件
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

它的作用是在创建容器时创建/ tmp / healthy文件。 5秒钟后,活动性探针将启动并检查/ tmp / healthy文件,这时容器中确实存在/ tmp / healthy文件。 30秒后,它将删除文件,并且活动性探针无法找到/ tmp / healthy文件,并重新启动容器。此过程将继续进行,并且活动性探针每30秒将无法通过健康检查。

如果仅添加

  • 触摸/ tmp /健康

活力探针应该工作正常

相关问题