Skip to content

Commit

Permalink
Add unit test and readme update for AWS_VPC_ENI_MTU for Egress plugin…
Browse files Browse the repository at this point in the history
… behavior.
  • Loading branch information
orsenthil committed Jul 3, 2024
1 parent b0ef946 commit f7e7ec6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Review the [Network Policy FAQ](./docs/network-policy-faq.md) for more informati
* This controller is automatically installed on the EKS Control Plane.
* [Network Policy Node Agent](https://github.com/aws/aws-network-policy-agent) implements Network Policies on nodes by creating eBPF programs.
* [AWS eBPF SDK for Go](https://github.com/aws/aws-ebpf-sdk-go) provides an interface to interact with eBPF programs on the node. This SDK allows for runtime introspection, tracing, and analysis of eBPF execution, aiding in identifying and resolving connectivity issues.
* [VPC Resource Controller](https://github.com/aws/amazon-vpc-resource-controller-k8s) manages Branch & Trunk Network Interfaces for Kubernetes Pods.
* [VPC Resource Controller](https://github.com/aws/amazon-vpc-resource-controller-k8s) manages Branch & Trunk Network Interfaces for Kubernetes Pods.

## ConfigMap

Expand Down Expand Up @@ -343,7 +343,7 @@ elasticity, but uses roughly half as many IPs as using WARM_IP_TARGET alone (32
This also improves the reliability of the EKS cluster by reducing the number of calls necessary to allocate or deallocate
private IPs, which may be throttled, especially at scaling-related times.

**NOTE!**
**NOTE!**
1. If `MINIMUM_IP_TARGET` is set, `WARM_ENI_TARGET` will be ignored. Please utilize `WARM_IP_TARGET` instead.
2. If `MINIMUM_IP_TARGET` is set and `WARM_IP_TARGET` is not set, `WARM_IP_TARGET` is assumed to be 0, which leads to the number of IPs attached to the node will be the value of `MINIMUM_IP_TARGET`. This configuration will prevent future ENIs/IPs from being allocated. It is strongly recommended that `WARM_IP_TARGET` should be set greater than 0 when `MINIMUM_IP_TARGET` is set.

Expand Down Expand Up @@ -697,6 +697,8 @@ This environment variable must be set for both the `aws-vpc-cni-init` and `aws-n

Note that enabling/disabling this feature only affects whether newly created pods have an IPv6 interface created. Therefore, it is recommended that you reboot existing nodes after enabling/disabling this feature.

The value set in `AWS_VPC_ENI_MTU` is used to configure the MTU size of the attached interface.

#### `ENABLE_V4_EGRESS` (v1.15.1+)

Type: Boolean as a String
Expand All @@ -707,6 +709,8 @@ Specifies whether PODs in an IPv6 cluster support IPv4 egress. If env is set to

Note that enabling/disabling this feature only affects whether newly created pods have an IPv4 interface created. Therefore, it is recommended that you reboot existing nodes after enabling/disabling this feature.

The value set in `AWS_VPC_ENI_MTU` is used to configure the MTU size of the attached interface.

#### `IP_COOLDOWN_PERIOD` (v1.15.0+)

Type: Integer as a String
Expand Down
28 changes: 28 additions & 0 deletions cmd/aws-vpc-cni/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"encoding/json"
"os"
"testing"

Expand Down Expand Up @@ -48,6 +49,33 @@ func TestGenerateJSONPlusBandwidthAndTuning(t *testing.T) {
assert.NoError(t, err)
}

// Validate setting environment AWS_VPC_ENI_MTU, takes effect for egress-cni plugin
func TestEgressCNIPlugin(t *testing.T) {
_ = os.Setenv(envEnIPv4Egress, "true")
_ = os.Setenv(envPodMTU, "5000")
assert.True(t, validateMTU(envEniMTU))

// Use a temporary file for the parsed output.
tmpfile, err := os.CreateTemp("", "temp-aws-vpc-cni.conflist")
assert.NoError(t, err)
defer os.Remove(tmpfile.Name())

err = generateJSON(awsConflist, tmpfile.Name(), getPrimaryIPMock)
assert.NoError(t, err)

// Read the json file and verify the MTU value for the egress-cni plugin
var jsonData map[string]interface{}
jsonFile, err := os.ReadFile(tmpfile.Name())
assert.NoError(t, err)

err = json.Unmarshal(jsonFile, &jsonData)
assert.NoError(t, err)

plugins, _ := jsonData["plugins"].([]interface{})
assert.Equal(t, "egress-cni", plugins[1].(map[string]interface{})["type"])
assert.Equal(t, "5000", plugins[1].(map[string]interface{})["mtu"])
}

func TestMTUValidation(t *testing.T) {
// By default, ENI MTU and pod MTU should be valid
assert.True(t, validateMTU(envEniMTU))
Expand Down

0 comments on commit f7e7ec6

Please sign in to comment.