jjdoherty
jjdoherty

Reputation: 504

Kuberentes Update Policy Wait Until Actually Ready

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.

Upvotes: 0

Views: 382

Answers (1)

kool
kool

Reputation: 3613

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
  • initialDelaySeconds: Number of seconds after the container has started before liveness or readiness probes are initiated. Defaults to 0 seconds. Minimum value is 0.

  • periodSeconds: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.

Upvotes: 1

Related Questions