Maximum Pods per Node in GKE

Maximum Pods per Node in GKE In this post, we’ll explore a case study related to configuring the “Pods per Node” parameter in Google Kubernetes Engine (GKE) and how it can impact a cluster’s scalability. Let’s analyze the limitations and ca

Source comparison and review notes
  • Automated pair-review warning (AI bilingual content review): The Spanish source has the Max-Pods-to-CIDR allocation table and a detailed migration/recreation procedure; English replaces them with three high-level steps, so it is a shortened translation.

In this post, we’ll explore a case study related to configuring the “Pods per Node” parameter in Google Kubernetes Engine (GKE) and how it can impact a cluster’s scalability. Let’s analyze the limitations and capabilities of this setting and the importance of proper network planning when configuring Node Pools.

The Issue: IP Space Exhaustion

We encountered an IP_SPACE_EXHAUSTED error while attempting to increase the number of nodes in our cluster through autoscaling. The error suggested that the IP address space allocated to the nodes was exhausted. However, our allocated IP range for GKE nodes, a CIDR /24 range (providing 252 IPs), seemed sufficient as we had only 8 running nodes.

Plain text
IP_SPACE_EXHAUSTED

Upon further investigation, we found this warning message:

Plain text
Warning FailedScaleUp 48s (x2 over 6m32s) cluster-autoscaler Node scale up in zones us-east4-b associated with this pod failed: IP space exhausted. Pod is at risk of not being scheduled.

This message indicated that the number of IP addresses assigned to the pods had been exhausted, preventing the cluster from scaling properly.

Root of the Problem: Pods Per Node

The root cause was tied to the subnet assigned for the pods in the cluster and the maximum number of pods per node:

  • The CIDR block designated for the pods was a /20, which allows for 4096 IPs.
  • The number of pods per node was set to the maximum default value of 256.

This led to a situation where we could only allocate a maximum of 8 nodes in the cluster.

But why? Let’s explain by diving into how the Pods per Node value in GKE affects IP allocation.

“Pods per Node” in GKE

The “Pods per Node” setting determines the size of the CIDR blocks assigned to each node in GKE, from which the pods on that node are allocated IP addresses. While this setting has a default value at the cluster level, it can be overridden at the level of each Node Pool in the cluster.

The maximum pods per node configuration is immutable once assigned to a node pool, which is why it’s crucial to consider this during the planning stage for each node group.

Understanding IP Allocation for Each Node Pool

Now that we understand the importance of this value, let’s consider how GKE assigns CIDRs to nodes:

  • With the default setting of 110 pods per node, GKE assigns a /24 block to each node, reserving 256 IPs.
  • Each block of IPs must contain at least twice the number of reserved IPs.

In our case, the IP_SPACE_EXHAUSTED error happened due to this allocation mechanism:

  • Our pod CIDR block was /20, which provides 4096 available IPs.
  • The default setting was 256 pods per node, which meant that each node had a /23 range (512 reserved IPs).
  • As a result, the available nodes were limited to 4096 / 512 = 8.

This configuration results in a cluster with high compute capacity per node, which did not fit our requirements. Thus, we needed to find an alternative to solve this issue.

How to Fix the Error

To resolve the IP_SPACE_EXHAUSTED error, a disruptive but effective solution is required: recreating the Node Pool with a lower “pods per node” configuration.

Steps for the Solution:

  1. Plan a new IP allocation strategy for the cluster.
  2. Recreate the Node Pool with a reduced Pods per Node setting.
  3. Adjust the network range for more efficient IP utilization.

By following these steps, you can prevent the IP exhaustion issue and improve the scalability of your GKE cluster.


Written by Mateo Di Loreto

Thanks for reading. The learning continues in the next article.