Cloud and Container Basics
readinessProbe:
httpGet:
path: /ready
port: 8080
periodSeconds: 5A web application cannot handle requests for about 60 seconds after starting, while it loads its cache, and returns 503 from /ready during that time. Which of the following correctly describes the effect of adding the settings above to the Pod's container?
- AWhile /ready fails, the Pod is removed from the Service's routing targets and receives no requests, and the container is not restarted
- BThe container is restarted each time /ready fails, so it keeps restarting before the cache has finished loading
- CUntil /ready succeeds, the Pod is not assigned to any node, and the container is not started
Show answer and explanation
Answer: A. While /ready fails, the Pod is removed from the Service's routing targets and receives no requests, and the container is not restarted
A readiness probe checks whether a container is ready to accept requests and, while it fails, removes the Pod from the Service's routing targets. An HTTP probe treats a response of at least 200 and below 400 as success, so no requests are routed while 503 is returned, and requests arrive once the application is ready. Restarting the container on failure is the job of a liveness probe; giving an application that is slow to start only a liveness probe with a short interval can cause repeated restarts. Which node a Pod runs on is decided by the scheduler, not by probes.
- A. Correct. A readiness probe decides whether requests are routed to the Pod.
- B. Restarting on failure is done by a liveness probe. A readiness probe failure does not restart the container.
- C. Probes are run against containers that have already been assigned to a node and started. Assignment is decided by the scheduler.