An administrator runs 'kubectl drain node01 --ignore-daemonsets --force' to prepare node01 for maintenance. However, a pod running a critical application is evicted and becomes unschedulable. Which flag could prevent eviction of that specific pod?
Trap 1: --grace-period=0
This flag controls the duration in seconds given to pods to terminate gracefully before being forcefully terminated. While setting it to zero forces immediate deletion of the evicted pods, it does not bypass or resolve the block caused by pods utilizing local storage. Therefore, it cannot be used to safely prevent or force the eviction of local-data pods during a drain operation.
Trap 2: --pod-selector='app=critical'
The kubectl drain command does not support a --pod-selector flag to filter which pods are evicted during a node drain. Instead, the command targets all non-daemonset pods on the specified node to ensure it can be safely decommissioned. To exclude specific pods from eviction, administrators must use other mechanisms like PodDisruptionBudgets or controller configurations.
Trap 3: --evict-unscheduled-pods
This parameter is entirely fabricated and does not exist in the Kubernetes CLI toolset. Unscheduled pods do not reside on any active node and therefore do not need to be evicted during a node maintenance operation. The kubectl drain command only targets active, running, or scheduled pods currently assigned to the node being drained.
- A
--grace-period=0
Why wrong: This flag controls the duration in seconds given to pods to terminate gracefully before being forcefully terminated. While setting it to zero forces immediate deletion of the evicted pods, it does not bypass or resolve the block caused by pods utilizing local storage. Therefore, it cannot be used to safely prevent or force the eviction of local-data pods during a drain operation.
- B
--pod-selector='app=critical'
Why wrong: The kubectl drain command does not support a --pod-selector flag to filter which pods are evicted during a node drain. Instead, the command targets all non-daemonset pods on the specified node to ensure it can be safely decommissioned. To exclude specific pods from eviction, administrators must use other mechanisms like PodDisruptionBudgets or controller configurations.
- C
--delete-local-data=false
By default, kubectl drain will refuse to evict pods that store data locally using emptyDir volumes to prevent accidental data loss. Setting --delete-local-data=false (or omitting --delete-emptydir-data in newer Kubernetes versions) ensures the drain command fails if such pods are present, thereby safeguarding critical workloads that rely on local ephemeral storage. This flag acts as a protective gatekeeper for stateful workloads during maintenance.
- D
--evict-unscheduled-pods
Why wrong: This parameter is entirely fabricated and does not exist in the Kubernetes CLI toolset. Unscheduled pods do not reside on any active node and therefore do not need to be evicted during a node maintenance operation. The kubectl drain command only targets active, running, or scheduled pods currently assigned to the node being drained.