<p>I want to utilize <a href="https://github.com/helm/helm/blob/master/docs/charts_hooks.md" rel="nofollow noreferrer">Charts Hooks</a>'s <code>post-install</code> to do some action on my deployment's container.</p>

<p>For example, I have a <code>php-fpm</code> container that consists of a <code>Laravel</code> application, and I want to run <code>php artisan key:gen</code> on install. Since it's a one time command so I couldn't place it on the <code>postStart</code> lifecycle, otherwise it would keep overwriting the <code>APP_KEY</code>.</p>

<p>How can I use <strong><em>Charts Hooks</em></strong> to achieve it? Or is there a better way?</p>

Cloud Soh Jun Fu
<p>Your job needs to run a container that contains <code>kubectl</code> and you would execute this script to exec into another container. Since <code>kubectl exec</code> <a href="https://github.com/kubernetes/kubernetes/issues/8876" rel="nofollow noreferrer">doesn't support selection by labels</a> you need to retrieve the pod name beforehand:</p>

<pre><code>$pod=$(kubectl get pods --no-headers -o custom-columns=":metadata.name" -l YOUR-LABELS=YOUR-VALUES)
kubectl exec $pod php artisan key:gen
</code></pre>
