Senior
Tell about working with Kubernetes: what is the difference between liveness probe and readiness probe? Why are there two resource requests and limits?
sobes.tech AI
Answer from AI
Liveness probe checks whether the application is alive, meaning it has not crashed or become unresponsive. If the liveness probe fails, Kubernetes restarts the container. This helps automatically recover crashed or frozen services.
Readiness probe checks whether the application is ready to accept traffic. If the readiness probe fails, Kubernetes does not send requests to this pod, but the container is not restarted. This is important during application startup or updates.
Requests and limits of resources specify different things:
- Requests are the guaranteed minimum resources (CPU, memory) that Kubernetes reserves for the container. The scheduler uses these values to determine on which node to place the pod.
- Limits are the maximum resources the container can use. If the container exceeds the limit, for example, in memory, it may be killed.
Example configuration in Pod spec:
resources:
requests:
memory: "128Mi"
cpu: "250m"
limits:
memory: "256Mi"
cpu: "500m"
Thus, requests ensure scheduling stability, and limits control resource consumption so that one container does not "consume" everything.