<p>I am basically looking for mechanics similair to init containers with a caveat, that I want it to run after pod is ready (responds to readinessProbe for instance). Are there any hooks that can be applied to readinessProbe, so that it can fire a job after first sucessfull probe?</p>
<p>thanks in advance</p>

Łukasz
<p>you can use some short lifecycle hook to pod or say container.</p>
<p>for example</p>
<pre><code>lifecycle:
      postStart:
        exec:
          command: [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;echo In postStart &gt; /dev/termination-log&quot;]
</code></pre>
<p>it's postStart hook so I think it will work.</p>
<p>But Post hook is async function so as soon as container started it will be triggered sometime may possible before the entry point of container it triggers.</p>
<p><strong>Update</strong></p>
<p>Above <strong>postStart</strong> runs as soon as the container is <strong>created</strong> not when it's <strong>Ready</strong>.</p>
<p>So I you are looking for when it become read you have to use either <strong>startup</strong> probe.</p>
<p><strong>Startup</strong> probe is like Readiness &amp; Liveness probe only but it's one time. <strong>Startup</strong> <strong>probe</strong> check for application <strong>Readiness</strong> once the application is Ready <strong>liveness</strong> <strong>probe</strong> takes it's place.</p>
<p>Read More about <a href="https://startupProbe:%20%20%20httpGet:%20%20%20%20%20path:%20/healthz%20%20%20%20%20port:%20liveness-port%20%20%20failureThreshold:%2030%20%20%20periodSeconds:%2010" rel="nofollow noreferrer">startup probe</a></p>
<p>So from the <strong>startup</strong> <strong>probe</strong> you can invoke the <strong>Job</strong> or Run any type of <strong>shell script</strong> file it will be one time, also it's after your application sends <strong>200</strong> to <strong>/healthz</strong> <strong>Endpoint</strong>.</p>
<pre><code>startupProbe:
  exec:
    command:
      - bin/bash
      - -c
      - ./run-after-ready.sh
  failureThreshold: 30
  periodSeconds: 10 
</code></pre>
<p>file <strong>run-after-ready.sh</strong> in container</p>
<pre><code>#!/bin/sh
curl -f -s -I &quot;http://localhost/healthz&quot; &amp;&gt;/dev/null &amp;&amp; echo OK || echo FAIL
.
. #your extra code or logic, wait, sleep you can handle now everything
.
</code></pre>
<p>You can add more checks or conditions <strong>shell script</strong> if the application <strong>Ready</strong> or <strong>some API</strong> as per need.</p>
