Octet

An EKS cluster stops scheduling pods because the subnets ran out of IPs. Why does that happen, and how do you fix it?

Show the answer

Say this first

The AWS VPC CNI gives every pod a real VPC address from secondary IPs on the node's ENIs, and it keeps a warm pool of spare addresses per node. Busy clusters burn through small subnets fast. Fixes, in order of effort: tune the warm pool, turn on prefix delegation so each ENI slot holds a /28, use custom networking to put pods in a large secondary CIDR such as one from 100.64.0.0/10, or run the cluster on IPv6.

Go deeper

Why it runs out

  • Max pods per node is bounded by ENIs times IPs per ENI. The classic formula is ENIs x (IPs per ENI - 1) + 2. An m5.large has 3 ENIs with 10 IPs each, so 3 x 9 + 2 = 29 pods.
  • The CNI pre-allocates: by default it keeps a whole spare ENI's worth of addresses warm on every node. Fifty nodes can reserve hundreds of idle addresses.

Fixes

FixWhat it doesWatch out for
WARM_IP_TARGET, MINIMUM_IP_TARGETKeep fewer idle IPs per nodeMore EC2 API calls when pods churn
Prefix delegationAssigns /28 prefixes (16 addresses) per ENI slot, raising pods per nodeNeeds free contiguous /28s; fragmented subnets fail. Nitro instances only
Custom networkingENIConfig per AZ puts pods in subnets from a secondary VPC CIDRThe primary ENI no longer hosts pods, so max pods drops
IPv6 clusterPods get IPv6 from a huge prefixEvery dependency must handle IPv6 or go through egress translation

Custom networking sketch

  1. Add a secondary CIDR to the VPC, for example 100.64.0.0/16.
  2. Create pod subnets per AZ from it.
  3. Set AWS_VPC_K8S_CNI_CUSTOM_NETWORK_CFG=true and create one ENIConfig per AZ.
  4. Pods take addresses from the large range; nodes keep their routable addresses. Pod traffic leaving the VPC is SNATed to the node IP by default, so the 100.64 range does not need to be routable on-prem.

Traps

  • Sizing EKS subnets as /24s because "we only have ten nodes".
  • Enabling prefix delegation on a fragmented subnet and getting allocation failures.
How did you do?