Try Sailor Cloud - 25% off!

Claim Now
Back to all posts

Kubernetes Probes: Liveness, Readiness, and Startup

Kubernetes Probes: Liveness, Readiness, and Startup

Health probes ensure your applications are running correctly and receiving traffic appropriately.

Probe Types

ProbePurposeFailure Action
LivenessIs container healthy?Restart container
ReadinessIs container ready for traffic?Remove from Service
StartupHas container started?Kill container

Probe Mechanisms

HTTP Probe

livenessProbe:
  httpGet:
    path: /health
    port: 8080
    httpHeaders:
    - name: Custom-Header
      value: Awesome
  initialDelaySeconds: 5
  periodSeconds: 10
  failureThreshold: 3

TCP Probe

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

Exec Probe

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

Probe Configuration

ParameterDescriptionDefault
initialDelaySecondsDelay before first probe0
periodSecondsHow often to probe10
timeoutSecondsProbe timeout1
successThresholdMin consecutive successes1
failureThresholdFailures before action3

Liveness Probe

Restarts container if unhealthy:

apiVersion: v1
kind: Pod
metadata:
  name: liveness-demo
spec:
  containers:
  - name: app
    image: my-app
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
      initialDelaySeconds: 10
      periodSeconds: 5
      failureThreshold: 3

Readiness Probe

Removes pod from service if not ready:

spec:
  containers:
  - name: app
    image: my-app
    readinessProbe:
      httpGet:
        path: /ready
        port: 8080
      initialDelaySeconds: 5
      periodSeconds: 5

Startup Probe

For slow-starting applications. Disables other probes until success:

spec:
  containers:
  - name: app
    image: slow-starter
    startupProbe:
      httpGet:
        path: /started
        port: 8080
      failureThreshold: 30
      periodSeconds: 10
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080

Complete Example

apiVersion: v1
kind: Pod
metadata:
  name: probe-demo
spec:
  containers:
  - name: app
    image: my-app
    ports:
    - containerPort: 8080
    startupProbe:
      httpGet:
        path: /started
        port: 8080
      failureThreshold: 30
      periodSeconds: 10
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
      periodSeconds: 10
    readinessProbe:
      httpGet:
        path: /ready
        port: 8080
      periodSeconds: 5

Best Practices

  1. Always configure readiness probes
  2. Use startup probe for slow apps
  3. Keep probe endpoints lightweight
  4. Don’t check dependencies in liveness
  5. Set appropriate thresholds

Practice Health Probes

Probe configuration appears in CKAD exams. Practice at Sailor.sh.

Start Free Practice