<p>I'm using Jenkins and Kubernetes to perform this actions.</p>

<p>Since my loadBalancer needs a healthy pod I had to add the livenessProbe to my pod.</p>

<p>My configuration for the pod:</p>

<pre><code>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
</code></pre>

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

<blockquote>
  <p>/tmp/healthy;</p>
</blockquote>

<p>command and it's timed out.</p>

<p>The error response I get looks like this:</p>

<pre><code>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!
</code></pre>

<hr>

<p>When I type <strong>kubectl get events</strong>
I get the following response:</p>

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

<p>Any hints on how to solve this?</p>

<p>I have read this <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/" rel="nofollow noreferrer">documentation</a> for the liveness and I took the config for it from there.</p>

DaAmidza
<p>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 <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/" rel="nofollow noreferrer">link</a> </p>

<p>they have purposely removed /tmp/healthy file after </p>

<pre><code>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
</code></pre>

<p>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.</p>

<p>If you only add </p>

<ul>
<li>touch /tmp/healthy </li>
</ul>

<p>The liveness probe should work well</p>
