kubernetes kubernetes/cka

[Kubernetes Readiness Probe: Tutorial & Examples - Kubecost Blog](https://blog.kubecost.com/blog/kubernetes-readiness-probe/
Kubernetes Readiness Probe - Guide & Examples
🌟 Configure Liveness, Readiness and Startup Probes | Kubernetes

Core Idea

Kubernetes probes decide a container’s fate: liveness kills and restarts a stuck container, readiness only pulls it out of Service endpoints, and startup protects slow-booting apps until liveness takes over.

  • Liveness fails on a deadlocked app that is still running; readiness fails while an app finishes initializing, removing it from endpoints without a restart; a startup probe disables liveness until it succeeds (e.g. JVM warm-up).
  • Three check types: HTTP httpGet, command exec, and tcpSocket.
  • Timing knobs: initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, successThreshold.

Health Probes

Health check simply ensure that the main process of your application is always running. If it isn’t , Kubernetes restarts it.

Liveness Probe

Checks if the application inside a container is still running.
If the liveness probe fails, K8s kills the container and restarts it.

Example: A deadlocked application that is running but not functioning properly.

livenessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 3
  periodSeconds: 10

Readiness Probe

Checks if the container is ready to accept traffic,
If the readiness probe fails, the container is removed from the list of available endpoint, but it is not restared.

Example : An application that requires some time to initialize before it can handle requests.

readinessProbe:
  httpGet:
    path: /ready
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 10

Startup Probe

Used to check if a container has successfully started.
If a startup probe is configured, the liveness probe is disabled until the startup probe succeeds.

Example : Applications with long startup times (e.g., a Java application that requires time for JVM warm-up).

startupProbe:
  httpGet:
    path: /start
    port: 8080
  failureThreshold: 30
  periodSeconds: 10

Other Types of Health Checks

  • HTTP Request (httpGet) – Kubernetes sends an HTTP request to a specified path.
  • Command Execution (exec) – Kubernetes runs a command inside the container.
  • TCP Socket (tcpSocket) – Kubernetes checks if a port is open.

Key Params

  • initialDelaySeconds – Time to wait before the first probe.
  • periodSeconds – Frequency of health checks.
  • timeoutSeconds – Time before a probe times out.
  • failureThreshold – Number of failed attempts before the container is restarted.
  • successThreshold – Number of successful attempts before marking as healthy.