<p>I have a k8s cronjob run my docker image <code>transaction-service</code>.</p>
<p>It starts and gets its job done successfully. When it's over, I expect the pod to terminate but... <code>istio-proxy</code> still lingers there:</p>
<p><a href="https://i.stack.imgur.com/NdnGQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NdnGQ.png" alt="containers" /></a></p>
<p>And that results in:</p>
<p><a href="https://i.stack.imgur.com/qehiJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qehiJ.png" alt="unready pod" /></a></p>
<p>Nothing too crazy, but I'd like to fix it.</p>
<p>I know I should call <code>curl -X POST http://localhost:15000/quitquitquit</code></p>
<p>But I don't know where and how. I need to call that quitquitquit URL only when transaction-service is in a completed state. I read about <code>preStop</code> lifecycle hook, but I think I need more of a <code>postStop</code> one. Any suggestions?</p>

<p>You have a few options here:</p>
<ol>
<li>On your job/cronjob spec, add the following lines and your job immediately after:</li>
</ol>
<pre><code>command: [&quot;/bin/bash&quot;, &quot;-c&quot;]
args:
 - |
   trap &quot;curl --max-time 2 -s -f -XPOST http://127.0.0.1:15020/quitquitquit&quot; EXIT
   while ! curl -s -f http://127.0.0.1:15020/healthz/ready; do sleep 1; done
   echo &quot;Ready!&quot;
   &lt; your job &gt;
</code></pre>
<ol start="2">
<li>Disable Istio injection at the Pod level in your Job/Cronjob definition:</li>
</ol>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  ...
spec:
  ...
  jobTemplate:
    spec:
      template:
        metadata:
          annotations:
            # disable istio on the pod due to this issue:
            # https://github.com/istio/istio/issues/11659
            sidecar.istio.io/inject: &quot;false&quot;
</code></pre>
<p>Note: The annotation should be on the Pod's template, not on the Job's template.</p>
