Readiness and Liveliness
Pod Lifecycle
A pod has a Status and some Conditions
POD Status
| stage | Pod Status | Desc |
|---|---|---|
| Pod Created | Pending | Waiting For Scheduler |
| Pod Scheduled | Container Creating | Images Pulled and Container Starts |
| Container Running | Running | Container Ready and Running |
kubectl describe pod {podname} will give reason for why its stuck
Pod Conditions
| Pod Conditions | True | False |
|---|---|---|
| PodScheduled | Pod is Scheduled | Pod is Created Waiting for Scheduler |
| Initialized | Pod is Initialized | Pod Creating |
| ContainersReady | All Containers are Ready | Containers still strating up |
| Ready | Pod is ready and containers healthy | pod is not ready containers unhealthy |
What does healthy mean?
Readiness Probes
A test to make sure the container is ready to accept traffic and serve the application
1apiVersion:
2kind: Pod
3metadata:
4 name: simple-webapp-color
5spec:
6 containers:
7 - name: simple-webapp-color
8 image: simple-webapp-color
9 ports:
10 - containerPort: 8080
11
12 readinessProbe:
13 httpGet:
14 path: /api/ready
15 port: 8080
There arer 3 kinds of readiness probesHTTP Test
1readinessProbe:
2 httpGet:
3 path: /api/ready
4 port: 8080
5 initialDelaySeconds: 10
6 periodSeconds: 5 # How often
7 failureThreshold: 8 #attempts
TCP TEST
1readinessProbe:
2 tcpSocket:
3 port: 8080
4 initialDelaySeconds: 10
5 periodSeconds: 5 # How often
6 failureThreshold: 8 #attempts
Exec Command
1readinessProbe:
2 exec:
3 command:
4 - cat
5 - /app/is_ready
6 initialDelaySeconds: 10
7 periodSeconds: 5 # How often
8 failureThreshold: 8 #attempts
Liveness Probe
1apiVersion:
2kind: Pod
3metadata:
4 name: simple-webapp-color
5spec:
6 containers:
7 - name: simple-webapp-color
8 image: simple-webapp-color
9 ports:
10 - containerPort: 8080
11
12 livenessProbe:
13 httpGet:
14 path: /api/ready
15 port: 8080
There arer 3 kinds of readiness probesHTTP Test
1livenessProbe:
2 httpGet:
3 path: /api/ready
4 port: 8080
5 initialDelaySeconds: 10
6 periodSeconds: 5 # How often
7 failureThreshold: 8 #attempts
TCP TEST
1livenessProbe:
2 tcpSocket:
3 port: 8080
4 initialDelaySeconds: 10
5 periodSeconds: 5 # How often
6 failureThreshold: 8 #attempts
Exec Command
1livenessProbe:
2 exec:
3 command:
4 - cat
5 - /app/is_ready
6 initialDelaySeconds: 10
7 periodSeconds: 5 # How often
8 failureThreshold: 8 #attempts