Why Can't One Pod Leave During a Kubernetes Cluster Upgrade?
In this article
During a Kubernetes cluster upgrade, a single pod cannot simply leave or be removed because the upgrade process is designed to maintain the overall availability and integrity of the cluster's control plane and worker nodes. The short answer is that pods are managed by controllers (like Deployments or StatefulSets) and are tied to nodes; an upgrade requires coordinated node-level operations (draining, kubelet updates, and uncordoning) that affect all pods on a node, not just one. This article explains the mechanics, why individual pod eviction is not a standalone step, and what you can do if you need to move a specific pod.
Background: How Kubernetes Upgrades Work
Kubernetes cluster upgrades involve updating multiple components: the control plane (kube-apiserver, controller-manager, scheduler, etcd) and the worker nodes (kubelet, kube-proxy, container runtime). The process is typically sequential and versioned—you cannot skip minor versions, and each component must be upgraded in a specific order. For worker nodes, the standard approach is to:
- Cordon the node (mark it unschedulable) so no new pods are placed there.
- Drain the node, which evicts all pods gracefully, respecting PodDisruptionBudgets (PDBs).
- Upgrade the kubelet and runtime on the node.
- Uncordon the node so it can accept pods again.
This node-centric process means that pods are not individually targeted; they are evicted as part of the node drain. A single pod cannot "leave" independently because the upgrade is about updating the node's software, and all pods on that node must be moved to allow the node to be updated safely.
Why Individual Pod Eviction Isn't a Step
Pods are ephemeral and designed to be replaced, not preserved. When you drain a node, the kubelet sends a termination signal to each pod, waits for the grace period (default 30 seconds), and then forcefully kills it if needed. The pod's controller (e.g., a Deployment) then creates a replacement pod on another node. This is the core of Kubernetes' self-healing design—pods are cattle, not pets.
If you tried to "leave" one pod behind during an upgrade, you would break this model. The pod would remain on a node that is about to be upgraded, and the kubelet would be stopped, causing the pod to be terminated anyway. Moreover, the pod's IP address and assigned resources would be lost, and the controller would see the pod as unhealthy and reschedule it. So, there is no mechanism to exempt a single pod from a node drain; the system is designed to treat all pods equally.
How to Move a Specific Pod If You Must
If you have a critical pod that you want to move to a different node before an upgrade (e.g., a stateful database), you have a few options:
- Delete the pod manually: If the pod is managed by a controller, deleting it will cause the controller to create a replacement on another node (provided there is capacity and the pod's scheduling constraints allow it). This is the simplest way to "move" a pod.
- Use pod anti-affinity or nodeSelector: If the pod must land on a specific node, you can add a nodeSelector or affinity rule to its spec, then delete the pod so it is rescheduled according to the new constraints.
- Use a StatefulSet with a headless service: For stateful workloads, you can scale down the StatefulSet to 0 replicas, then scale it back up after the upgrade, but this causes downtime.
None of these methods are part of the upgrade process itself; they are manual interventions you perform before starting the node drain.
Common Misconception: Pod Eviction vs. Node Drain
A frequent misunderstanding is that you can "evict" a single pod via the Kubernetes API (using the eviction subresource) and that this is related to upgrades. Eviction is a mechanism to voluntarily terminate a pod, but it is not used during upgrades. During a node drain, the kubelet performs evictions for all pods on the node, respecting PDBs. If you manually evict a pod, it is just a normal termination—it does not affect the upgrade process. The upgrade still requires the node to be drained, and any pods that were manually evicted are simply gone (or rescheduled by their controller).
PodDisruptionBudgets and Upgrade Safety
PodDisruptionBudgets (PDBs) are crucial during upgrades. They define how many replicas of a workload can be unavailable at a time. When you drain a node, the kubelet checks the PDB for each pod. If evicting a pod would violate the PDB (e.g., it would bring the number of available replicas below the minimum), the eviction is blocked. This is why you might see a drain hang—it's waiting for the PDB to allow eviction. A single pod cannot leave if doing so would violate its PDB, because the system prioritizes availability over the upgrade speed.
If you have a critical pod that must stay up, you can set a PDB with minAvailable: 1 to prevent it from being evicted during a drain. However, this also means the node cannot be upgraded until you manually allow the eviction (e.g., by scaling up the workload or temporarily removing the PDB).
What Happens If You Try to Bypass the Process
Some administrators attempt to "leave" a pod by not draining the node and just upgrading the kubelet in place. This is dangerous and not supported. The kubelet upgrade typically requires a restart, which will kill all pods on the node. Even if you could somehow keep the pod running during the kubelet restart, the pod would be in an unknown state—its status might be lost, and the API server might consider it dead. The pod would then be rescheduled by its controller, defeating the purpose. In short, there is no safe way to have a pod survive a node upgrade.
Frequently Asked Questions
Can I exclude a specific pod from a node drain?
No, there is no built-in way to exclude a single pod from a drain. The drain command evicts all pods on the node, except those with a PDB that blocks eviction. If you need to keep a pod running, you must either set a PDB that prevents its eviction (which will also block the drain) or move the pod manually before draining.
What happens to a pod if I don't drain a node before upgrading?
If you skip the drain and upgrade the kubelet directly, the pod will likely be terminated when the kubelet restarts. The pod's status will become unknown, and after a timeout, the controller will reschedule it. This can cause downtime and data loss if the pod is stateful. Always drain the node first.
Why does my drain hang on a pod with a PDB?
The drain is waiting for the PDB to allow eviction. If the PDB specifies minAvailable: 2 and only 2 replicas are running, evicting one would drop availability to 1, so the eviction is blocked. You need to scale up the workload or temporarily adjust the PDB to proceed.
Can I move a pod to a specific node before an upgrade?
Yes, you can use a nodeSelector or affinity rule to target a specific node, then delete the pod so it is rescheduled. However, this only works if the target node has capacity and meets all other scheduling constraints. For stateful pods, consider using a StatefulSet with persistent volumes that can be reattached.
Is there a way to upgrade a node without evicting pods?
No, not for standard node upgrades. The kubelet must be restarted, which requires stopping all pods. Some managed Kubernetes services offer "in-place" upgrades that use a rolling node pool replacement, but that still involves pod eviction. There is no way to upgrade the underlying node software while keeping pods running.
What is the difference between cordon and drain?
Cordon marks a node as unschedulable, preventing new pods from being placed there. Drain evicts existing pods. You typically cordon first, then drain. During an upgrade, you cordon to stop new pods, drain to remove existing ones, upgrade, then uncordon to allow new pods.