Overview
By default, Amazon VPC CNI will assign Pods an IP address selected from the primary subnet. The primary subnet is the subnet CIDR that the primary ENI is attached to, usually the subnet of the node/host. If the subnet CIDR is too small, the CNI may not be able to acquire enough secondary IP addresses to assign to your Pods. This is a common challenge for EKS IPv4 clusters. Custom networking is one solution to this problem and is supported by Truefoundry. For more details, please refer to the Amazon EKS Custom Networking documentation.Setup
To setup custom networking in EKS, you need to follow the steps below:- Attach a secondary CIDR to the VPC and create new subnets with the secondary CIDR in the same AZs as the primary subnet. For example, if the primary subnet is 10.0.0.0/16, you can attach a secondary CIDR of 100.64.0.0/16 (RFC6598) to the VPC and if you have primary subnets in 3AZs which are used for the EKS nodes, you have to create 3 new subnets with the secondary CIDR in the same AZs.
- Ensure that secondary subnets are added to the route tables of your primary subnets. This should happen automatically when you create the subnets.
- We need to make the AWS VPC CNI aware of the secondary subnets. If you have used TrueFoundry’s terraform code to setup your cluster, you need to make the following change in the EKS module
- In all other cases you can set the same env variable by running the following commands from the kubernetes cli:
- Create the following
ENIConfigresources in the cluster for each AZ of the EKS nodes
- Restart the nodes one by one to apply the changes in the cluster networking. Pods will be rescheduled to the new nodes with the secondary IP addresses.