<p>We are using secret as environment variables on pod, but every time we have updated on secrets, we are redeploying the pods to take changes effect. We are looking for a mechanism where Pods get restarted automatically whenever secrets gets updated. Any help on this?</p>
<p>Thanks in advance.</p>

ramesh reddy
<p>There are many ways to handle this.</p>
<p>First, use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="noreferrer">Deployment</a> instead of &quot;naked&quot; Pods that are not managed. The Deployment will create new Pods for you, when the Pod template is changed.</p>
<p>Second, to manage Secrets may be a bit tricky. It would be great if you can use a setup where you can use <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/#secretgenerator" rel="noreferrer">Kustomize SecretGenerator</a> - then each new <code>Secret</code> will get its unique name. In addition, that unique name is reflected to the <code>Deployment</code> automatically - and your pods will automatically be recreated when a <code>Secret</code> is changed - this match your origin problem. When <code>Secret</code> and <code>Deployment</code> is handled this way, you apply the changes with:</p>
<pre><code>kubectl apply -k &lt;folder&gt;
</code></pre>
