<p>I am new to Kubernetes. I have written a deployment for my python console application. this app is subscribed to NATS (message queue).</p>
<p>I have written command in <strong>liveness prob</strong> to check the connection_id(my app connection id) in the nats server is present. otherwise, restart the pod as the application is not running properly, in that case.</p>
<p>I have tried different commands. for example</p>
<pre><code>        livenessProbe:
          exec:
            command:
            - sh
            - -c
            #- curl -s nats:8222/connz?cid=$(cat /tmp/cid) | python3 -c &quot;import sys, json; print(json.load(sys.stdin)['connections'][0]['cid'])&quot; | echo

            #- curl -s http://nats:8222/connz?cid=$(cat /tmp/cid) | grep &quot;$(cat /tmp/cid)&quot;
            - curl -s http://nats:8222/connz?cid=$(cat /tmp/cid) | grep &quot;cid&quot;
          initialDelaySeconds: 10
          periodSeconds: 10
</code></pre>
<p>and another few curl commands. then when I remove <code>/tmp/cid</code> file. <strong>it should fail, right? But it does not.</strong></p>
<p>If I run this command
<code>curl -s http://nats:8222/connz?cid=$(cat /tmp/cid) | grep -c &quot;\&quot;cid\&quot;: $(cat /tmp/cid)&quot; </code></p>
<p>I get <code>io.k8s.api.core.v1.ExecAction.command: got &quot;map&quot;, expected &quot;string&quot;</code> this issue.</p>
<p>Any suggestion?</p>

<pre class="lang-sh prettyprint-override"><code>curl -s http://localhost:8222/connz?cid=$(cat /tmp/cid) | grep -c &quot;cid.* $(cat /tmp/cid),&quot;
</code></pre>
<p>This finally worked for me.</p>
<p>Stuck with the issue for 2 days :(</p>
