Kubernetes (K8s) (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
Liveness, Readiness, and Startup Probes: Differences and Use Cases.
junior LevelCode ExamplekubernetesBasic
In Simple Words:
- Startup Probe:
- Tests if a slow-starting legacy application (e.g. Java Spring Boot taking 90 seconds to boot) has finished initializing.
- While running, it disables Liveness and Readiness checks so the Kubelet doesn't mistakenly kill the slow-starting container.
- Liveness Probe:
- Tests if the application process is still alive and healthy.
- If it fails $N$ consecutive times, Kubelet kills and restarts the container.
- Do not point to external database checks; if the database blips, killing the web container won't fix the database!
- Readiness Probe:
- Tests if the container is ready to accept user network traffic.
- If it fails, Kubernetes removes the Pod IP from the Service endpoints / load balancer. Traffic stops, but the container is NOT killed.
yaml
readinessProbe:
httpGet:
path: /healthz/ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3