Liveness Probe gets timed

10/29/2018

I'm using Jenkins and Kubernetes to perform this actions.

Since my loadBalancer needs a healthy pod I had to add the livenessProbe to my pod.

My configuration for the pod:

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

The issue that happens is when I want to deploy the code (CD over Jenkins) it comes to the touch

/tmp/healthy;

command and it's timed out.

The error response I get looks like this:

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!

When I type kubectl get events I get the following response:

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

Any hints on how to solve this?

I have read this documentation for the liveness and I took the config for it from there.

-- DaAmidza
google-compute-engine
google-kubernetes-engine
jenkins
kubernetes

1 Answer

10/29/2018

As can be seen from the link you are referring . The example is to help you understand the working of liveness probe. I the example below from this link

they have purposely removed /tmp/healthy file after

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

what this does is it creates /tmp/healthy file when the container is created. After 5 seconds the liveness probe kicks in and checks for /tmp/healthy file , at this moment the container does have a /tmp/healthy file present . After 30 seconds it deletes the file and liveness probe fails to find the /tmp/healthy file and restarts the container. This process will continue to go on and liveness probe will fail the health check after every 30 seconds.

If you only add

  • touch /tmp/healthy

The liveness probe should work well

-- Shashank Pai
Source: StackOverflow