Kuberentes Update Policy Wait Until Actually Ready

10/12/2020

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?

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.

-- jjdoherty
kubernetes

1 Answer

11/3/2020

Posting @David Maze comment as community wiki for better visibility:

You need a readiness probe; the pod won't show as "ready" (and the deployment won't proceed) until the probe passes.

Example:

readinessProbe:
  exec:
    command:
    - cat
    - /tmp/healthy
  initialDelaySeconds: 5
  periodSeconds: 5
-- kool
Source: StackOverflow