<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>Readiness probes can stop traffic going to a pod but won't recreate it on failure, liveness probes however can.</p>
<p>If you have a readiness probe which checks the app is properly initialised (got the auth token) and hits an endpoint which only responds 200 when it has traffic won't be sent till it's initialised.</p>
<p>You can then have a liveness probe to check another endpoint (or the same with a start delay) as when liveness probes fail they will kill the pod after a certain amount of time.</p>
