<p>My application requires to communicate with a third party services over REST API, for which in needs to send a <code>POST</code> request to <code>/auth</code> and the third-party system responses with a token. that token can then be used for the subsequent calls and it's valid up to <code>12 hours</code>.</p>
<p>At the moment the <code>/auth</code> calls happen when the first request comes to the POD, and that takes few seconds. I am trying to make changes so that the POD always gets the token before serving any request.</p>
<p>The solution I am thinking is to use <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">Readiness Probe</a> in Kubernetes to get the api token before the POD become available. Is this the ideal way of solving the issue?</p>
<p>If so, <strong>how can I automatically re-create my POD every 12 hours?</strong> Because if I don't delete the pod after 12 hours, the token become invalid.</p>

Benjamin
<p>I think that this is answering your question: <a href="https://stackoverflow.com/questions/45762491/cronjob-in-kubernetes-to-restart-delete-the-pod-in-a-deployment">Cronjob in Kubernetes to restart (delete) the pod in a deployment</a></p>
<p>Another solution would be to use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">Kubernetes CronJob</a> - you can expose another endpoint that will refresh the token and call it every few hours.</p>
