Cloud and Container Basics
In Kubernetes, a Deployment with replicas: 3 is running three Pods. Which of the following correctly describes what happens when one of these Pods is deleted with kubectl delete pod?
- AThe Deployment's setting is also rewritten to replicas: 2, and two Pods keep running
- BA controller detects that the actual number has fallen below the specified 3 and creates one new Pod
- CThe other two Pods of the Deployment are also deleted, and the whole Deployment stops
Show answer and explanation
Answer: B. A controller detects that the actual number has fallen below the specified 3 and creates one new Pod
In Kubernetes, users declare a desired state such as "run three Pods", and controllers repeatedly observe the actual state and act to bring it closer to the declaration when they differ (reconciliation). Deleting one Pod makes the actual number 2, so the ReplicaSet controller creates a new Pod to return to 3. When a Pod is lost because a node fails, the same mechanism recreates it on another node. To really reduce the number of Pods, change the Deployment's replicas instead of deleting Pods.
- A. Deleting a Pod does not change the replicas declared in the Deployment. Pods are created to close the gap with the declaration.
- B. Correct. The controller closes the gap between the declared state and the actual state.
- C. Only the deleted Pod is affected. Unless the Deployment is deleted, the other Pods keep running.