<p><strong>I wanna have a trigger when I make a deployment of my React application, and my pod is finally <code>running</code></strong></p>
<p>I need this Kubernetes trigger, in order to launch another pod which is gonna copy/past the static files for another pod specific just made for static files. (I wanna do this to keep the old <code>bundle.js</code> if ever users on the application are still surfing with old bundles, this way I'll be able to make a fat PWA)</p>
<p>I don't wanna have to wait myself the end of the deployment (6 minutes of docker building enough to take a cup of tea)</p>
<p>When my React app is <code>Running</code> =&gt; My goal is to start a pod which is gonna make a <code>kubectl</code> command from inside the cluster and kill himself afterwards</p>
<p>The command from inside the pod is gonna be a simple copy/past <code>kubectl cp fresh-new-deployment/static pod-just-for-static-files/var/www</code></p>
<p>Everything is working fine in local, I just need the Kubernetes trigger ;)</p>
<p>I don't want to make a kubernetes CRON for this (or maybe this is the only way), or an every minute CRON ? what you recommend ?</p>
<p>Thanks I already typed in google <code>kubernetes trigger when pod running</code> there was nothing interesting.</p>

<p>Ideally you should use <code>init-containers</code> pattern described here <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/init-containers/</a></p>
<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/</a></p>
<p>Here are some ideas for how to use init containers:</p>
<p><em>Wait for a Service to be created, using a shell one-line command like:</em></p>
<pre><code>for i in {1..100}; do sleep 1; if dig myservice; then exit 0; fi; done; exit 1
</code></pre>
<p><em>Register this Pod with a remote server from the downward API with a command like:</em></p>
<pre><code>curl -X POST http://$MANAGEMENT_SERVICE_HOST:$MANAGEMENT_SERVICE_PORT/register -d 'instance=$(&lt;POD_NAME&gt;)&amp;ip=$(&lt;POD_IP&gt;)'
</code></pre>
<p><em>Wait for some time before starting the app container with a command like</em></p>
<pre><code>sleep 60
</code></pre>
