<p>According to the below documentation, the line &quot;HTTP - Executes an HTTP request against a specific endpoint on the Container.&quot;</p>
<p><a href="https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#hook-handler-implementations" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#hook-handler-implementations</a></p>
<p>Using preStop hook, I tried to curl to run the following script but it returns nothing. Is the prestop hook limited to use the Http request within the container i.e, localhost?</p>
<pre><code>echo &quot;test curl&quot; &gt; /proc/1/fd/1
echo $(curl -s /dev/null http://google.com) &gt; /proc/1/fd/1
echo $(curl -s -o /dev/null -w &quot;%{http_code}&quot; http://google.com) &gt; /proc/1/fd/1
</code></pre>

acm
<p>No, as I know you are not limited to use <code>preStop's httpGet</code> only withing the container. Your cointainer should just have access yo requested url, etc. So in your case you should have access to google.</p>
<p>May I know what exactly you wanna to achieve? Are you trying to redirect <code>curl</code> output to <code>proc with PID:1</code> ?</p>
<p>Your command perfectly works in containers(that has <code>curl</code> itself), when I specify <a href="https://docs.docker.com/config/containers/logging/" rel="nofollow noreferrer">redirect to STDOUT</a>, I mean <code>/proc/self/fd/1</code></p>
<pre><code>kubectl exec -ti curl -- bash
root@curl:/# echo $(curl -s -o /dev/null -w &quot;%{http_code}&quot; http://google.com) &gt; /proc/self/fd/1
301
</code></pre>
<p>Btw, you can use <code>exec</code> instead of <code>httpGet</code> in <code>preStop</code>, where you can combine <code>echo</code> and <code>curl</code></p>
<p>Yaml will be similar to</p>
<pre><code>lifecycle:
  preStop:
    exec:
      command: [&quot;curl&quot;, &quot;-XPOST&quot;, &quot;-s&quot;, &quot;http://google.com&quot; &gt; &quot;/proc/1/fd/1&quot;]
</code></pre>
<p>Please play with <code>command</code> and adjust for your needs. I havent tested it, wrote on flight</p>
