<p>this question is about k8s readiness probe.
I am trying to add the command in readiness probe curl to the new pod that is creating.</p>

<p>I mean that I want to check that the new pod that is created is ready to accept traffic, before the old one is terminated.
I alrady have a command that is execute in the readines probe, so it is not possible for me to add an httpGet in this way:</p>

<pre><code>readinessProbe:
  httpGet:
    path: /health
</code></pre>

<p>because I saw that there is an <a href="https://github.com/kubernetes/kubernetes/issues/37218" rel="nofollow noreferrer">issue</a> that it is not possible to add httpGet &amp; command that will be execute.</p>

<p>Therefore, I must add this curl to the script that is running each time before new pod is created.</p>

<pre><code>status=$( curl -s -o -k /dev/null -w %{http_code} /health); echo "statusCode: $status" if [ "$status" -ne "200" ]; exit 1 fi
</code></pre>

<p>My problem is that that it is not working, and using <code>kubectl describe po XXXXX</code> I see this output:</p>

<pre><code> Readiness probe failed: statusCode: 000000 if [ 000000 -ne 200 ]
</code></pre>

<p>So, I'm not sure how to make request to the new pod, because the only thing that I know about the new pod in this level is that it include an api named <strong>health</strong>.</p>

<p>am I making the request correct?</p>

Sariel
<p>You are missing some colons and a then.</p>

<p>You have:</p>

<pre><code>status=$( curl -s -o -k /dev/null -w %{http_code} /health); echo "statusCode: $status" if [ "$status" -ne "200" ]; exit 1 fi
</code></pre>

<p>instead of</p>

<pre><code>status=$( curl -s -o -k /dev/null -w %{http_code} /health); echo "statusCode: $status"; if [ "$status" -ne "200" ]; then exit 1; fi
</code></pre>
