AWS EKS maximum number of Pods per EC2 Node instance
AWS EKS supports native VPC networking with the Amazon VPC Container Network Interface (CNI) plugin for Kubernetes. Using this plugin allows Kubernetes Pods to have the same IP address inside the pod as they do on the VPC network. The plugin is an open-source project that is maintained on GitHub. For more information, see amazon-vpc-cni-k8s and Proposal: CNI plugin for Kubernetes networking over AWS VPC on GitHub. The Amazon VPC CNI plugin is fully supported for use on Amazon EKS and self-managed Kubernetes clusters on AWS.
The Amazon VPC CNI plugin for Kubernetes is deployed with each of your EC2 Nodes in a Daemonset with the name aws-node.
This is a great feature but it introduces a limitation in the number of Pods per EC2 Node instance. Whenever you deploy a Pod in the EKS worker Node, EKS creates a new IP address from VPC subnet and attach to the instance. You can find here https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#AvailableIpPerENI the maximum number of network interfaces and maximum number of IPs per interface.
The formula for defining the maximum number of Pods per EC2 Node instance is as follows:
N * (M-1) + 2
Where:
- N is the number of Elastic Network Interfaces (ENI) of the instance type
- M is the number of IP addresses per ENI
As an example, for a t3.small instance, this calculation is 3 * (4–1) + 2 = 11 Pods.
Here https://github.com/awslabs/amazon-eks-ami/blob/master/files/eni-max-pods.txt you can find also the calculated number of Pods.
By executing the following command, you can identify the total number of running Pods across all Kubernetes namespaces.
kubectl get pods — all-namespaces | grep -i running | wc -l