<p>I have a K8 cluster running with a deployment which has an update policy of RollingUpdate. How do I get Kubernetes to wait an extra amount of seconds or until some condition is met before marking a container as ready after starting?</p>
<p>An example would be having an API server with no downtime when deploying an update. But after the container starts it still needs X amount of seconds before it is ready to start serving HTTP requests. If it marks it as ready immediately once the container starts and the API server isn't actually ready there will be some HTTP requests that will fail for a brief time window.</p>

jjdoherty
<p>Posting @David Maze comment as community wiki for better visibility:</p>
<p>You need a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes" rel="nofollow noreferrer">readiness probe</a>; the pod won't show as &quot;ready&quot; (and the deployment won't proceed) until the probe passes.</p>
<p>Example:</p>
<pre><code>readinessProbe:
  exec:
    command:
    - cat
    - /tmp/healthy
  initialDelaySeconds: 5
  periodSeconds: 5
</code></pre>
<ul>
<li><p><code>initialDelaySeconds</code>: Number of seconds after the container has
started before liveness or readiness probes are initiated. Defaults
to 0 seconds. Minimum value is 0.</p>
</li>
<li><p><code>periodSeconds</code>: How often (in seconds) to perform the probe. Default
to 10 seconds. Minimum value is 1.</p>
</li>
</ul>
