CKAD — Probe Mechanisms

1 minute read

Probe Mechanisms

There are four ways a probe can check health:

1. HTTP GET

Makes an HTTP GET request to a specified path and port. Succeeds if the response code is 200–399.

livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
    httpHeaders:
    - name: X-Custom-Header
      value: probe
  initialDelaySeconds: 5
  periodSeconds: 10
  timeoutSeconds: 3
  failureThreshold: 3
  successThreshold: 1

Most common mechanism. Use for any app with an HTTP endpoint.

2. TCP Socket

Opens a TCP connection to the specified port. Succeeds if the connection is established.

livenessProbe:
  tcpSocket:
    port: 3306
  initialDelaySeconds: 10
  periodSeconds: 15

Best for databases and services that do not have HTTP endpoints.

3. Exec Command

Runs a command inside the container. Succeeds if the command exits with code 0.

livenessProbe:
  exec:
    command:
    - cat
    - /tmp/healthy
  initialDelaySeconds: 5
  periodSeconds: 10

Use when health checks require custom logic (checking files, running scripts).

4. gRPC (Kubernetes 1.27+)

Checks a gRPC health endpoint. Succeeds if the gRPC status is SERVING.

livenessProbe:
  grpc:
    port: 50051
  initialDelaySeconds: 5
  periodSeconds: 10

Configuration Parameters

Every probe type supports these timing parameters:

Parameter Description Default
initialDelaySeconds Seconds to wait before the first probe 0
periodSeconds How often to run the probe 10
timeoutSeconds How long to wait for a response 1
failureThreshold Consecutive failures before action 3
successThreshold Consecutive successes to be considered OK 1

Example timing: With initialDelaySeconds: 10, periodSeconds: 5, failureThreshold: 3 — the first probe runs at 10s. If it fails 3 times in a row, Kubernetes takes action at ~25s.

Choosing the Right Mechanism

Mechanism Best For Example
HTTP GET Web apps, APIs /healthz endpoint
TCP Socket Databases, caches MySQL port 3306
Exec Custom checks Check if file exists
gRPC gRPC microservices gRPC health protocol

Next: Liveness Probes

Updated: