<p>I'm using Kubernetes on Digitalocean cloud platform</p>
<p>the deckorized laravel app is running right now</p>
<p>and i need to run  <code>php artisan optimize:clear</code> to all pods which are loading the app</p>
<p>how can i do that?</p>
<p><strong>Edit:</strong></p>
<p>I got the solution</p>
<p>First step connect to pod container</p>
<pre><code>kubectl exec -it  pod_name -- /bin/bash
</code></pre>
<p>then</p>
<pre><code>php artisan optimize:clear
</code></pre>
<p><strong>or</strong></p>
<pre><code>kubectl exec -it pod_name -- /bin/bash -c &quot;php artisan  route:clear&quot;
</code></pre>

<p>You can build a bash file like the below:</p>
<pre><code>#!/bin/bash
PODS=$(kubectl get pods -n my-production | grep php-fpm | awk -F' *|/' '$2 == $3 &amp;&amp; $4 == &quot;Running&quot;' | awk {'print $1'} | column -t )
for POD in $PODS
do
    echo $POD
    kubectl -n my-production exec $POD -c php -- php artisan optimize:clear
done

echo &quot;Done!&quot;
</code></pre>
