<p>A container defined inside a deployment has a <code>livenessProbe</code> set up: by definition, it calls a remote endpoint and checks, whether response contains useful information or an empty response (which should trigger the pod's restart).</p>
<p>The whole definition is as follows (I removed the further checks for better clarity of the markup):</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: fc-backend-deployment
  labels:
    name: fc-backend-deployment
    app: fc-test
spec:
  replicas: 1
  selector:
    matchLabels:
      name: fc-backend-pod
      app: fc-test
  template:
    metadata:
      name: fc-backend-pod
      labels:
        name: fc-backend-pod
        app: fc-test
    spec:
      containers:
      - name: fc-backend
        image: localhost:5000/backend:1.3
        ports:
        - containerPort: 4044
        env:
        - name: NODE_ENV
          value: &quot;dev&quot;
        - name: REDIS_HOST
          value: &quot;redis&quot;
        livenessProbe:
          exec:
            command:
            - curl -X GET $BACKEND_SERVICE_HOST:$BACKEND_SERVICE_PORT/api/v3/stats | head -c 30 &gt; /app/out.log
          initialDelaySeconds: 20
          failureThreshold: 12
          periodSeconds: 10
</code></pre>
<p>I also tried putting the command into an array:</p>
<pre class="lang-yaml prettyprint-override"><code>command: [&quot;sh&quot;, &quot;-c&quot;, &quot;curl -X GET $BACKEND_SERVICE_HOST:$BACKEND_SERVICE_PORT/api/v3/stats&quot;, &quot;|&quot;, &quot;head&quot;, &quot;-c&quot;, &quot;30&quot;, &quot;&gt;&quot;, &quot;/app/out.log&quot;]
</code></pre>
<p>and splitting into separate lines:</p>
<pre class="lang-yaml prettyprint-override"><code>- /bin/bash
- -c
- curl
- -X
- GET
- $BACKEND_SERVICE_HOST:$BACKEND_SERVICE_PORT/api/v3/stats
- |
- head
- -c
- &quot;30&quot;
- &gt;
- /app/out.log
</code></pre>
<p>and even like this:</p>
<pre class="lang-yaml prettyprint-override"><code>command:
  - |
      curl -X GET $BACKEND_SERVICE_HOST:$BACKEND_SERVICE_PORT/api/v3/stats | head -c 30 &gt; /app/out.log
</code></pre>
<p>All attempts were made with and without <code>(/bin/ba)sh -c</code> - with the same result.</p>
<p>But, as you're reading this, you already know that none of these worked.</p>
<p>I know it by <code>exec</code>'ing into running container and trying to find the <code>/app/out.log</code> file - it wasn't present any time I watched the directory contents. It looks like the probe gets never executed.</p>
<p>The command run inside running container works just fine: data gets fetched and written to the specified file.</p>
<p>What might be causing the probe not to get executed?</p>

AbreQueVoy
<p>When using the <code>exec</code> type of probes, Kubernetes will <strong>not</strong> run a shell to process the command, it will just run the command directly. This means that you can only use a single command and that the <code>|</code> character is considered just another parameter of your <code>curl</code>.</p>
<p>To solve the problem, you need to use <code>sh -c</code> to exec shell code, something like the following:</p>
<pre><code>    livenessProbe:
      exec:
        command:
          - sh
          - -c
          - &gt;-
              curl -X GET $BACKEND_SERVICE_HOST:$BACKEND_SERVICE_PORT/api/v3/stats |
              head -c 30 &gt; /app/out.log
</code></pre>
