Skip to content

Clarification on Configuring Karpenter with Security Groups for Pods to Reflect the Real MaxPods Count

0

Hi,

According to the Karpenter documentation, when using Security Groups for Pods, it is recommended to reserve one ENI for the trunk interface by setting RESERVED_ENIS=1. This is meant to avoid discrepancies between the calculated maxPods and the node’s actual pod capacity.

However, when we reserve one ENI, the resulting maxPods calculation no longer seems to reflect the real number of pods that can be scheduled. This is because pods attached to branch ENIs (created by the VPC Resource Controller when Security Groups for Pods are enabled) are not considered in the standard maxPods formula, which only accounts for primary and secondary IPs on traditional ENIs.

In practice, this causes Karpenter to underestimate the node’s true pod capacity — especially for instance types where a single trunk ENI can support multiple branch ENIs and, therefore, a larger number of pods.

Could you please clarify:

How Karpenter should be configured (or patched) so that the maxPods calculation accurately reflects the additional pod capacity provided by branch interfaces?

Whether AWS plans to update the maxPods formula or provide guidance for environments where Security Groups for Pods are enabled?

This clarification would help ensure consistent pod scheduling and prevent nodes from being underutilized.

Thank you for your assistance,

asked a year ago354 views

1 Answer
0

When using Security Groups for Pods in Amazon EKS, there is indeed a discrepancy between the standard maxPods calculation and the actual pod capacity of a node. This occurs because pods using security groups are associated with branch interfaces that are not accounted for in the traditional maxPods formula.

The standard formula for calculating maxPods is: (Number of network interfaces for the instance type * (the number of IP addresses per network interface - 1)) + 2

However, when Security Groups for Pods is enabled, branch interface capacity is additive to existing instance type limits for secondary IP addresses. This means pods that use security groups are not counted against the max-pods value calculated by the standard formula.

When using Karpenter as your cluster autoscaler with Security Groups for Pods, you should configure the karpenter-global-settings configmap with aws.reservedENIs set to 1. This reserves one ENI for the trunk interface that manages the branch ENIs.

While this configuration ensures Karpenter won't allocate the trunk ENI for regular pod IP assignments, it does mean that the maxPods calculation will be lower than the actual capacity of the node. This is because the standard formula doesn't account for the additional capacity provided by branch interfaces.

Currently, there isn't an automatic way to make Karpenter aware of the additional capacity provided by branch interfaces. You have two options:

  1. Manually increase the max-pods value in your Karpenter configuration to account for the additional capacity. You can specify this through kubelet-extra-args.

  2. Accept that nodes may be underutilized according to the standard calculation, but in reality, they can accommodate more pods than the calculation suggests.

If you choose to manually increase the max-pods value, you should carefully consider the actual capacity of your instance types, taking into account both CPU and memory resources. For example, on smaller instance types like m5.large, you might exhaust CPU and memory resources before IP addresses, so setting an artificially high max-pods value could lead to resource contention.
Sources
Security Groups Per Pod - Amazon EKS
Amazon VPC CNI - Amazon EKS
Troubleshooting Amazon EKS networking issues at scale in an Enterprise scenario | AWS re:Post

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.