Readiness and Liveness Probe - Sandeep-K-Khandelwal/CKAD GitHub Wiki

Readiness Probe

Readiness Probe is a way to describe how the container will be treated as ready. This way Pod will become ready only when the container becomes ready and accept the traffic. Without a Readiness probe, the Pod starts accepting traffic as soon as the containers get created even though the underlying application is not ready.

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
spec:
  containers:
    - name: nginx-container
      image: nginx
  readinessProbe:
    httpGet:
      path: /api/ready
      port: 8080
    InitialDelaySeconds: 10
    PeriodSeconds: 5
    failureThreshold: 3
  readinessProbe:
    tcpSocket: 3306
  readinessProbe:
    exec:
      command:
        - cat
        - /apps/isReady

Liveness Probe

A Liveness probe is a way to tell POD whether the application in the container is healthy or not. This way if the application is not healthy, the pod can terminate the container and recreate it. Without the Liveness probe, Pod will continue to accept the traffic even the application inside the container is hanging or stuck.

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
spec:
  containers:
    - name: nginx-container
      image: nginx
  livenessProbe:
    httpGet:
      path: /api/healthy
      port: 8080
    InitialDelaySeconds: 10
    PeriodSeconds: 5
    failureThreshold: 3
  livenessProbe:
    tcpSocket: 3306
  livenessProbe:
    exec:
      command:
        - cat
        - /apps/isHealthy