We use machine learning technology to do auto-translation. Click "English" on top navigation bar to check Chinese version.
Automated IP address management for Multus Workers and Pods
Telco 5G and IMS container based workloads utilize
The post,
- Multus Worker Node group: Worker node subnets, and IP address management for the worker nodes, as each worker node ENI needs an IP address from the subnet.
- Multus Pod Networking: Multus Pod IP management from the worker node subnets, and pod communication in
Amazon Virtual Private Cloud (Amazon VPC) .
In this post, I’ll walk through the standard Multus nodegroup deployment approach, as well as the challenges and approaches to manage above topics when using the ipvlan CNI with your Multus workloads inside of an Amazon VPC.
Standard Multus Nodegroup deployment approach
The previous diagram represents a sample deployment of Multus workload with IPVLAN CNI, which will be referred to in this post. In this example, we have an Amazon EKS cluster and a node group with two worker nodes. Both worker nodes are attached with two subnets as follows:
- eth0 network: 10.10.12.0/24 (used for VPC CNI, i.e., primary pod interface)
- eth1 network: 10.10.1.0/24 (used for Multus ipvlan cni, i.e., pod secondary interface)
For the previous sample deployment approach, the deployment starts with the Amazon EKS cluster deployment, followed by the Amazon EKS node group deployment. Once the node groups are deployed, you can deploy the Multus CNI and relevant plugins to support your workloads. Once the plugins are deployed, you can deploy your workloads.
In the following section, I will discuss the deployment strategy for Multus Worker Node group and IP management.
Multus Worker Node group deployment and IP management
Multus Worker Node deployment
Self-managed Multus Node group, uses autoscaling group, providing resiliency (maintains the minimum number of workers) and scalability. The Autoscaling group utilizes
As shown in the following diagram, deployment starts with the Autoscaling Group creating the worker nodes with single interface (eth0) using the Launch templates. Once the workers are launched, a custom Lambda terminates the single interface nodes. This scale-in causes the “autoscaling:EC2_INSTANCE_TERMINATING” event, which triggers a custom Lambda and then drains the node/or does nothing.
After the completion of this event, the Autoscaling group scales-out to meet the desired capacity, causing the “autoscaling:EC2_INSTANCE_LAUNCHING” event. This event triggers a custom Lambda function, which adds secondary interfaces from the Multus subnets, with the Tag (key: node.k8s.amazonaws.com/no_manage” value: true).
EKS Multus node group Creation Flow
Worker Node IP management challenges
Autoscaling groups provide elasticity and resiliency to the Amazon EKS worker nodegroups, and uses DHCP IP allocation to all of the interfaces to support the same. On the other hand, for Multus pods, non-VPC IPAM CNIs (
Two different and disjointed IP allocation methods (DHCP and static) on the same subnet cause interesting challenge in workload deployment. Worker node IP assignment being DHCP is random, and since it has no knowledge of other static allocation, it can get any IP address from the planned static IP range for the pods. Multus IPAM CNI (
Solution
In the following sections, I will walk you through with two possible approaches to better manage the IP addressing of worker nodes and Multus workloads in a non-conflicting way.
Approach 1: Allocate Worker IPs statically with a custom Lambda
This solution approach works on the logical subnet sharing model, between the workers and pods. In this approach, worker nodes take the unallocated IPs from the beginning of the subnet, and the Multus pods take the unallocated IPs from end of the subnet. With this allocation strategy, IP address allocation isn’t random for worker node interfaces, and IP allocation happens statically from the first free available IPs from the subnet.
Refer to the GitHub repo
Approach 2: Use VPC subnet CIDR reservation (static) for the pods’ IP addresses
This approach uses the
Refer to the GitHub repo
Automated Multus Pod Networking
Now that the Amazon EKS cluster and the Multus node group are deployed with either of the previous approaches, you can deploy your workloads on Amazon EKS using Multus. As a next step, you will deploy the Multus CNI as mentioned in the
Now, let’s understand how IP communication works in VPC, approaches to enable the routing, and IP assignment for Multus pods in an automated way.
Multus Pod IP management and routing challenges
In the following example, note that when you deploy the Multus pods, the communication between pods on different workers doesn’t work, even if the security group rules/NACL aren’t blocking the traffic. However, intercommunication between pods on the same worker node works fine.
Here I will explain this behavior in details. The Amazon VPC cloud provides Layer 3 networking to its workloads. ENI is the logical networking entity which contains one or more IP address and corresponding MAC addresses. Amazon VPC routes the traffic to the correct destination, based on the IP address assigned to the ENI. Each ENI attached to the Amazon EC2 worker node must have the desired IP address(es) assigned to it.
For the primary interfaces of the Pod, Amazon VPC CNI assigns primary pod IP addresses (10.10.12.x in the previous example) to pod eth0 (VPC CNI managed interfaces) using DHCP, and assigns these IPs as secondary IPs on the worker node ENI. Non-VPC IPAM CNIs (whereabouts, host-local, static, etc.) allocate the IP address to Multus pod. Therefore, Amazon VPC won’t be aware of this IP address allocation. Furthermore, these IP addresses aren’t assigned as secondary IPs on the respective worker node ENI (in this example eth1).
Note that you can verify the same by examining the worker node ENIs on the Amazon EC2 console: Amazon EC2 console → Instances→ Select Instance (worker)→ Actions → Networking → Manage IP Addresses.
This problem is solved when the IP addresses assumed by pods are assigned to the respective worker ENI. Once these IPs are assigned to the respective ENI (ex: eth1), Amazon VPC updates the mapping of the assigned IPs to the ENI to route the traffic to the designated Multus IP addresses.
In the following example, Multus pod IP addresses 10.10.1.80 and 10.10.1.82 are assigned as secondary IP addresses on the eth1 ENI of the first worker node. Similarly, the 10.10.1.81 secondary IP is assigned to the second worker node eth1 ENI.
Automated solution
Amazon EC2 assign IP address/unassign IP address API calls can automate the IP assignment on the worker node ENIs. The sample Python code and script from the
The automation approaches discussed in the following don’t require any change in the application image or source code. You can leverage a custom “IP management” container on these pods to perform the automation of the IP allocation on the respective worker Node ENIs without any impact on applications containers or their architecture. You can enhance the spec of the workload pod/deployment/statefulset with this additional container.
Refer to
Approach 1: InitContainer based IP management solution
This solution works for most ipvlan CNI pods without special/custom handling such as floating IP (explained in the next approach). This approach doesn’t add the constraint of additional CPU/memory requirements on the worker.
This “IP management” container gets executed as a first container while the POD is in the init state. This container checks the IP address of the pod and allocates the IP addresses to the ENI while the pod is in the init state. Once the Multus IP addresses are successfully assigned to the worker node ENIs, this initContainer will terminate and the pod will come out of the init state.
Refer to the
Approach 2: Sidecar IP management solution
In this approach, the “IP management” container runs as a sidecar container. Moreover, unlike the initContainer, it constantly monitors the pod IP addresses on Multus interfaces for new or changed IP addresses. This is helpful for the pods having custom “Floating IP” handling for the active/standby pod, and based on internal logic, “Floating IP” fails over to the standby pod without traffic disruption. In this case, the sidecar constantly monitors the pod for IP address changes, so there is additional usage of the CPU/Memory (minimal) of this container per-Multus-based pods.
Refer to the
Cleaning up
Refer to
Conclusion
This post outlines the challenges that customers face during the IP allocation, management, and separation of worker node and Multus pod IP addresses within the Amazon VPC cloud. Furthermore, it describes how Multus pods work in the Amazon EKS and Amazon VPC scope, and route the traffic in the VPC.
Moreover, this post provides a sample automation methodology for the Amazon EKS node group and IP management automation of the Multus pods, without any change in the software/images.
For simplicity, this post only demonstrated the IPv4 handling in the previous examples. However, the sample code in the
The mentioned AWS GenAI Services service names relating to generative AI are only available or previewed in the Global Regions. Amazon Web Services China promotes AWS GenAI Services relating to generative AI solely for China-to-global business purposes and/or advanced technology introduction.