Skip to content

CICD-154 · Set liveness and readiness separately ​

Encyclopedia · Kubernetes fundamentals · All snippets

Previous · CICD-153 · Next · CICD-155

1. Where it fits ​

  • Placement Under the target container in a Deployment manifest.
  • Prerequisites isolated Kubernetes namespace, kubectl and reviewed manifests.
  • Platforms kubernetes, local-lab.

2. Copy the snippet ​

yaml
readinessProbe:
  httpGet: {path: /readyz, port: 8000}
livenessProbe:
  httpGet: {path: /livez, port: 8000}

3. How it works ​

Readiness controls whether a Pod is eligible to serve traffic. Liveness can trigger a restart on repeated failures, so each probe should check an appropriate route.

Readiness and liveness probe outcomes affect different Kubernetes behaviors.

flowchart TD
  N1["Running container"]
  N2{"Ready"}
  N1 --> N2
  N3{"Alive"}
  N1 --> N3
  N4["Remove from ready endpoints"]
  N2 -->|No| N4
  N5["Restart container"]
  N3 -->|Repeated failure| N5

4. Verify the result ​

Merge under a container. Readiness controls serving eligibility while liveness can restart a container.

Validation syntax-validated (YAML parse). Status definitions.