Ensuring Serving Capacity During GKE Node Drains

PCD By islever Editorial Last updated

Deploying containers to GKE.

Short answer

B Configure the Pod replica count to be 10% more than the current replica count to ensure sufficient serving capacity during node drains.

Question

You have an application running on a GKE cluster. Your application has a stateless web frontend, and has a high-availability requirement. Your cluster is set to automatically upgrade, and some of your nodes need to be drained. You need to ensure that the application has a serving capacity of 10% of the Pods prior to the drain. What should you do?
  1. Configure a Vertical Pod Autoscaler (VPA) to increase the memory and CPU by 10% and set the updateMode to Auto.
  2. Configure the Pod replica count to be 10% more than the current replica count. Correct Answer
  3. Configure a Pod Disruption Budget (PDB) value to have a minAvailable value of 10%.
  4. Configure the Horizontal Pod Autoscaler (HPA) maxReplicas value to 10% more than the current replica count.

Key Takeaways

To maintain serving capacity during GKE node drains, configure the Pod replica count to be 10% higher than current levels. This creates a buffer that absorbs pod evictions during automatic upgrades, ensuring high availability for stateless web frontends without relying on dynamic autoscalers.

Expert Analysis

The scenario demands maintaining a specific serving capacity during node drains, which points directly to the mechanics of workload availability management in Kubernetes. The correct action is configuring the Pod replica count to be 10% more than the current replica count, ensuring that when nodes are removed, sufficient pods remain to handle the load. This approach leverages the basic scaling principles of GKE to guarantee capacity before disruption occurs.

Horizontal Scaling Mechanics and Capacity Guarantees

Horizontal Pod Autoscaling (HPA) operates by monitoring resource utilization metrics such as CPU or memory usage against defined thresholds to determine when to scale workloads up or down. It does not manage pod counts based on maintenance events like node drains; instead, it reacts to actual load patterns. Vertical Pod Autoscaler (VPA) adjusts the resource requests and limits for individual pods but does not change the number of replicas, meaning it cannot ensure that a minimum number of pods are available across the cluster. Increasing the base replica count is a static configuration decision that increases the overall capacity of the deployment. By setting the replica count higher, you create a buffer that absorbs the loss of pods during voluntary disruptions. This method ensures that the application has enough instances to maintain its required serving capacity, regardless of the underlying node health or upgrade status. The key distinction lies in the trigger: HPA responds to demand, while replica count adjustments respond to infrastructure changes and capacity planning requirements. In this scenario, the requirement is to have 10% capacity prior to drain, which implies a need for extra resources to cover the temporary reduction in available nodes. Therefore, increasing the replica count is the most direct way to achieve this capacity buffer without relying on dynamic scaling triggers that may not activate quickly enough or at all during a controlled drain operation.

Decisive Condition: Node Drain vs. Load Spike

The decisive condition in this scenario is the scheduled node drain associated with automatic upgrades, which constitutes a voluntary disruption rather than an unexpected failure or traffic spike. When nodes are drained, pods are evicted from those nodes to run on other healthy nodes within the cluster. If the cluster is already running at full capacity with no spare resources, draining nodes will result in pod failures or scheduling delays until new nodes become available. To prevent this, the application must have excess capacity available. Configuring the Pod Disruption Budget (PDB) restricts the number of pods that can be disrupted simultaneously, but it does not increase the total number of pods or the cluster's capacity. A PDB of minAvailable: 10% would mean that only 10% of pods can be unavailable, which is the opposite of what is needed to maintain serving capacity during a drain. Instead, the requirement is to ensure that there are enough pods to serve traffic even after some are moved or terminated. Increasing the replica count provides this surplus. The question specifies a high-availability requirement and a stateless web frontend, which makes horizontal scaling the appropriate strategy. The automatic upgrade process will drain nodes one by one, so having a buffer of extra pods ensures that the frontend remains responsive throughout the upgrade cycle. This is a proactive measure to handle infrastructure maintenance, distinct from reactive measures taken during outages.

Boundary Between PDB and Replica Count

The exact boundary between Pod Disruption Budgets and replica count configurations lies in their function: PDBs limit the rate of voluntary disruptions, while replica counts define the total desired state of the deployment. A PDB acts as a guardrail, preventing too many pods from being taken down at once, but it does not provide additional capacity. If you set a PDB with minAvailable: 90%, you are saying that at least 90% of your pods must remain running during a disruption. However, if your cluster nodes are being drained, the scheduler needs to place the displaced pods onto remaining nodes. If those nodes are full, the pods will fail to schedule. A PDB does not solve the scheduling constraint; it only prevents the eviction from happening too aggressively. On the other hand, increasing the replica count increases the total number of pods the deployment wants to run. This creates a pool of extra pods that can absorb the loss of pods from drained nodes. For example, if you have 100 pods and need 10% capacity during a drain, setting the replica count to 110 ensures that even if 10 pods are evicted, you still have 100 running. This is a capacity planning issue, not a disruption control issue. The confusion often arises because both concepts relate to availability, but they operate at different levels: PDBs control the disruption window, while replica counts control the resource baseline. Understanding this distinction is crucial for designing resilient applications on GKE.

Step Where Action Takes Effect

The step in the mechanism where the chosen action takes effect is the initial scheduling and ongoing reconciliation loop of the Kubernetes Deployment controller. When the replica count is increased, the controller detects the deviation from the desired state and creates new pod objects. These pods are then scheduled onto nodes by the kube-scheduler. During the node drain process, the node controller marks the node as cordoned and begins evicting pods. The existing pods are moved to other nodes, and the extra pods created by the increased replica count provide the necessary headroom. Without these extra pods, the scheduler might struggle to find space for the evicted pods on the remaining nodes, leading to service degradation. The action of increasing the replica count is effective because it pre-allocates the necessary resources and pod instances before the disruption occurs. This is a static configuration that persists until manually changed, unlike HPA which dynamically adjusts based on metrics. The effectiveness of this approach is realized during the voluntary disruption phase, where the extra capacity ensures that the application can continue to serve traffic despite the reduction in available nodes. This highlights the importance of aligning scaling strategies with operational procedures like automatic upgrades to maintain high availability.

Exam Strategy

When dealing with GKE maintenance operations like automatic upgrades, always consider the impact on pod scheduling. If the requirement is to maintain capacity during node drains, increasing the replica count is often the most reliable method. Distinguish this from PDBs, which only limit disruption rates, and HPAs, which react to load. Proactively adjust replicas to create a buffer for expected infrastructure changes.

Practice All PCD Questions

Access 84 questions with complete answers and detailed explanations.

View Full PCD Practice Test →

← Back to PCD Study Guide