diff --git a/charts/aws-vpc-cni/values.yaml b/charts/aws-vpc-cni/values.yaml index 957e3846ef..d9683e73ae 100644 --- a/charts/aws-vpc-cni/values.yaml +++ b/charts/aws-vpc-cni/values.yaml @@ -78,6 +78,7 @@ env: DISABLE_NETWORK_RESOURCE_PROVISIONING: "false" ENABLE_IPv4: "true" ENABLE_IPv6: "false" + VPC_CNI_VERSION: "v1.15.0" # this flag enables you to use the match label that was present in the original daemonset deployed by EKS # You can then annotate and label the original aws-node resources and 'adopt' them into a helm release diff --git a/cmd/aws-k8s-agent/main.go b/cmd/aws-k8s-agent/main.go index 7d8cea4343..8e0b59a447 100644 --- a/cmd/aws-k8s-agent/main.go +++ b/cmd/aws-k8s-agent/main.go @@ -40,7 +40,7 @@ func _main() int { version.RegisterMetric() // Check API Server Connectivity - if err := k8sapi.CheckAPIServerConnectivity(appName); err != nil { + if err := k8sapi.CheckAPIServerConnectivity(); err != nil { log.Errorf("Failed to check API server connectivity: %s", err) return 1 } diff --git a/cmd/cni-metrics-helper/main.go b/cmd/cni-metrics-helper/main.go index 7c4d592f05..4193327531 100644 --- a/cmd/cni-metrics-helper/main.go +++ b/cmd/cni-metrics-helper/main.go @@ -105,7 +105,7 @@ func main() { log.Infof("Starting CNIMetricsHelper. Sending metrics to CloudWatch: %v, LogLevel %s, metricUpdateInterval %d", options.submitCW, logConfig.LogLevel, metricUpdateInterval) - clientSet, err := k8sapi.GetKubeClientSet(appName) + clientSet, err := k8sapi.GetKubeClientSet() if err != nil { log.Fatalf("Error Fetching Kubernetes Client: %s", err) os.Exit(1) diff --git a/config/master/aws-k8s-cni-cn.yaml b/config/master/aws-k8s-cni-cn.yaml index 8e6b7a1b1c..96afc51920 100644 --- a/config/master/aws-k8s-cni-cn.yaml +++ b/config/master/aws-k8s-cni-cn.yaml @@ -459,6 +459,8 @@ spec: value: "false" - name: ENABLE_PREFIX_DELEGATION value: "false" + - name: VPC_CNI_VERSION + value: "v1.15.0" - name: WARM_ENI_TARGET value: "1" - name: WARM_PREFIX_TARGET diff --git a/config/master/aws-k8s-cni-us-gov-east-1.yaml b/config/master/aws-k8s-cni-us-gov-east-1.yaml index d0d03376d6..5788335a0a 100644 --- a/config/master/aws-k8s-cni-us-gov-east-1.yaml +++ b/config/master/aws-k8s-cni-us-gov-east-1.yaml @@ -459,6 +459,8 @@ spec: value: "false" - name: ENABLE_PREFIX_DELEGATION value: "false" + - name: VPC_CNI_VERSION + value: "v1.15.0" - name: WARM_ENI_TARGET value: "1" - name: WARM_PREFIX_TARGET diff --git a/config/master/aws-k8s-cni-us-gov-west-1.yaml b/config/master/aws-k8s-cni-us-gov-west-1.yaml index 1923208067..a84935b49f 100644 --- a/config/master/aws-k8s-cni-us-gov-west-1.yaml +++ b/config/master/aws-k8s-cni-us-gov-west-1.yaml @@ -459,6 +459,8 @@ spec: value: "false" - name: ENABLE_PREFIX_DELEGATION value: "false" + - name: VPC_CNI_VERSION + value: "v1.15.0" - name: WARM_ENI_TARGET value: "1" - name: WARM_PREFIX_TARGET diff --git a/config/master/aws-k8s-cni.yaml b/config/master/aws-k8s-cni.yaml index ab2dc0f725..7f27f7643f 100644 --- a/config/master/aws-k8s-cni.yaml +++ b/config/master/aws-k8s-cni.yaml @@ -459,6 +459,8 @@ spec: value: "false" - name: ENABLE_PREFIX_DELEGATION value: "false" + - name: VPC_CNI_VERSION + value: "v1.15.0" - name: WARM_ENI_TARGET value: "1" - name: WARM_PREFIX_TARGET diff --git a/pkg/awsutils/awssession/session.go b/pkg/awsutils/awssession/session.go index b25e772432..e26f75a39c 100644 --- a/pkg/awsutils/awssession/session.go +++ b/pkg/awsutils/awssession/session.go @@ -22,6 +22,7 @@ import ( "time" "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger" + "github.com/aws/amazon-vpc-cni-k8s/utils" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/endpoints" "github.com/aws/aws-sdk-go/aws/request" @@ -31,13 +32,13 @@ import ( // Http client timeout env for sessions const ( - httpTimeoutEnv = "HTTP_TIMEOUT" - maxRetries = 10 + httpTimeoutEnv = "HTTP_TIMEOUT" + maxRetries = 10 + envVpcCniVersion = "VPC_CNI_VERSION" ) var ( - version string - log = logger.Get() + log = logger.Get() // HTTP timeout default value in seconds (10 seconds) httpTimeoutValue = 10 * time.Second ) @@ -89,6 +90,7 @@ func New() *session.Session { // injectUserAgent will inject app specific user-agent into awsSDK func injectUserAgent(handlers *request.Handlers) { + version := utils.GetEnv(envVpcCniVersion, "") handlers.Build.PushFrontNamed(request.NamedHandler{ Name: fmt.Sprintf("%s/user-agent", "amazon-vpc-cni-k8s"), Fn: request.MakeAddToUserAgentHandler( diff --git a/pkg/k8sapi/k8sutils.go b/pkg/k8sapi/k8sutils.go index 24eb27287e..9861e6ac44 100644 --- a/pkg/k8sapi/k8sutils.go +++ b/pkg/k8sapi/k8sutils.go @@ -13,6 +13,7 @@ import ( eniconfigscheme "github.com/aws/amazon-vpc-cni-k8s/pkg/apis/crd/v1alpha1" "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger" + "github.com/aws/amazon-vpc-cni-k8s/utils" rcscheme "github.com/aws/amazon-vpc-resource-controller-k8s/apis/vpcresources/v1alpha1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/wait" @@ -86,7 +87,7 @@ func StartKubeClientCache(cache cache.Cache) { // CreateKubeClient creates a k8s client func CreateKubeClient(appName string) (client.Client, error) { - restCfg, err := getRestConfig(appName) + restCfg, err := getRestConfig() if err != nil { return nil, err } @@ -122,9 +123,9 @@ func CreateKubeClient(appName string) (client.Client, error) { return k8sClient, nil } -func GetKubeClientSet(appName string) (kubernetes.Interface, error) { +func GetKubeClientSet() (kubernetes.Interface, error) { // creates the in-cluster config - config, err := getRestConfig(appName) + config, err := getRestConfig() if err != nil { return nil, err } @@ -137,8 +138,8 @@ func GetKubeClientSet(appName string) (kubernetes.Interface, error) { return clientSet, nil } -func CheckAPIServerConnectivity(appName string) error { - restCfg, err := getRestConfig(appName) +func CheckAPIServerConnectivity() error { + restCfg, err := getRestConfig() if err != nil { return err } @@ -166,12 +167,12 @@ func CheckAPIServerConnectivity(appName string) error { }) } -func getRestConfig(appName string) (*rest.Config, error) { +func getRestConfig() (*rest.Config, error) { restCfg, err := ctrl.GetConfig() if err != nil { return nil, err } - restCfg.UserAgent = appName + restCfg.UserAgent = os.Args[0] + "-" + utils.GetEnv("VPC_CNI_VERSION", "") if endpoint, ok := os.LookupEnv("CLUSTER_ENDPOINT"); ok { restCfg.Host = endpoint } diff --git a/pkg/utils/eventrecorder/eventrecorder.go b/pkg/utils/eventrecorder/eventrecorder.go index b0f59d181e..3af53d6c58 100644 --- a/pkg/utils/eventrecorder/eventrecorder.go +++ b/pkg/utils/eventrecorder/eventrecorder.go @@ -50,7 +50,7 @@ type EventRecorder struct { } func Init(k8sClient client.Client) error { - clientSet, err := k8sapi.GetKubeClientSet(appName) + clientSet, err := k8sapi.GetKubeClientSet() if err != nil { log.Fatalf("Error Fetching Kubernetes Client: %s", err) return err diff --git a/scripts/generate-cni-yaml.sh b/scripts/generate-cni-yaml.sh index aaf0db21a5..69c9583ada 100755 --- a/scripts/generate-cni-yaml.sh +++ b/scripts/generate-cni-yaml.sh @@ -79,6 +79,7 @@ jq -c '.[]' $REGIONS_FILE | while read i; do --set nodeAgent.image.region=$ecrRegion \ --set nodeAgent.image.domain=$ecrDomain \ --set nodeAgent.image.tag=$NODE_AGENT_VERSION \ + --set env.VPC_CNI_VERSION=$VPC_CNI_VERSION \ --namespace $NAMESPACE \ $SCRIPTPATH/../charts/aws-vpc-cni > $NEW_CNI_RESOURCES_YAML # Remove 'managed-by: Helm' annotation