<p>I'd like to run a particular Kubernetes job whenever the pod of particular deployment restarts.</p>
<p>In particular, I have a Redis deployment.  It is not backed by permanent storage.  When the pod in the Redis deployment restarts, I'd like to populate some keys in Redis.</p>
<p>Is there a way to trigger a job on pod restart?</p>

Laizer
<p>The best option comes to my mind is an k8s operator - A simple python/go script watches your target pod (by label, name, namespace, etc.) and performs some actions when the state changes.</p>
<p>An operator is just a deployment with special features. There are various ways to implement, one of them is <a href="https://sdk.operatorframework.io/docs/building-operators/golang/quickstart/" rel="nofollow noreferrer">https://sdk.operatorframework.io/docs/building-operators/golang/quickstart/</a></p>
<p>You can also use <a href="https://github.com/kubernetes-client/python#examples" rel="nofollow noreferrer">https://github.com/kubernetes-client/python#examples</a> (check the second example).</p>
<p>You can get rid of the job and write your redis logic inside the operator itself.</p>
