diff --git a/kubetest2/go.mod b/kubetest2/go.mod index e502d9b8c..40a64f8cd 100644 --- a/kubetest2/go.mod +++ b/kubetest2/go.mod @@ -6,14 +6,14 @@ toolchain go1.22.1 require ( github.com/aws/aws-sdk-go v1.51.2 - github.com/aws/aws-sdk-go-v2 v1.32.2 + github.com/aws/aws-sdk-go-v2 v1.32.6 github.com/aws/aws-sdk-go-v2/config v1.27.8 github.com/aws/aws-sdk-go-v2/service/autoscaling v1.40.4 github.com/aws/aws-sdk-go-v2/service/cloudformation v1.48.0 github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.36.3 github.com/aws/aws-sdk-go-v2/service/ec2 v1.151.1 - github.com/aws/aws-sdk-go-v2/service/eks v1.41.2 - github.com/aws/smithy-go v1.22.0 + github.com/aws/aws-sdk-go-v2/service/eks v1.53.0 + github.com/aws/smithy-go v1.22.1 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/octago/sflags v0.2.0 github.com/pkg/errors v0.9.1 @@ -69,8 +69,8 @@ require ( github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.17.8 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.15.4 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.25 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.25 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect github.com/aws/aws-sdk-go-v2/service/ecr v1.27.3 // indirect github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.23.3 // indirect diff --git a/kubetest2/go.sum b/kubetest2/go.sum index f48a2282e..442a7f863 100644 --- a/kubetest2/go.sum +++ b/kubetest2/go.sum @@ -132,6 +132,8 @@ github.com/aws/aws-sdk-go-v2 v1.26.0 h1:/Ce4OCiM3EkpW7Y+xUnfAFpchU78K7/Ug01sZni9 github.com/aws/aws-sdk-go-v2 v1.26.0/go.mod h1:35hUlJVYd+M++iLI3ALmVwMOyRYMmRqUXpTtRGW+K9I= github.com/aws/aws-sdk-go-v2 v1.32.2 h1:AkNLZEyYMLnx/Q/mSKkcMqwNFXMAvFto9bNsHqcTduI= github.com/aws/aws-sdk-go-v2 v1.32.2/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= +github.com/aws/aws-sdk-go-v2 v1.32.6 h1:7BokKRgRPuGmKkFMhEg/jSul+tB9VvXhcViILtfG8b4= +github.com/aws/aws-sdk-go-v2 v1.32.6/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= github.com/aws/aws-sdk-go-v2/config v1.27.8 h1:0r8epOsiJ7YJz65MGcb8i91ehFp4kvvFe2qkq5oYeRI= github.com/aws/aws-sdk-go-v2/config v1.27.8/go.mod h1:XsmYKxYNuIhLsFddpNds+j9H5XKzjWDdg/SZngiwFio= github.com/aws/aws-sdk-go-v2/credentials v1.17.8 h1:WUdNLXbyNbU07V/WFrSOBXqZTDgmmMNMgUFzpYOKJhw= @@ -142,10 +144,14 @@ github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.4 h1:0ScVK/4qZ8CIW0k8jO github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.4/go.mod h1:84KyjNZdHC6QZW08nfHI6yZgPd+qRgaWcYsyLUo3QY8= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 h1:UAsR3xA31QGf79WzpG/ixT9FZvQlh5HY1NRqSHBNOCk= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21/go.mod h1:JNr43NFf5L9YaG3eKTm7HQzls9J+A9YYcGI5Quh1r2Y= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.25 h1:s/fF4+yDQDoElYhfIVvSNyeCydfbuTKzhxSXDXCPasU= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.25/go.mod h1:IgPfDv5jqFIzQSNbUEMoitNooSMXjRSDkhXv8jiROvU= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.4 h1:sHmMWWX5E7guWEFQ9SVo6A3S4xpPrWnd77a6y4WM6PU= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.4/go.mod h1:WjpDrhWisWOIoS9n3nk67A3Ll1vfULJ9Kq6h29HTD48= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21 h1:6jZVETqmYCadGFvrYEQfC5fAQmlo80CeL5psbno6r0s= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21/go.mod h1:1SR0GbLlnN3QUmYaflZNiH1ql+1qrSiB2vwcJ+4UM60= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.25 h1:ZntTCl5EsYnhN/IygQEUugpdwbhdkom9uHcbCftiGgA= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.25/go.mod h1:DBdPrgeocww+CSl1C8cEV8PN1mHMBhuCDLpXezyvWkE= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY= github.com/aws/aws-sdk-go-v2/service/autoscaling v1.40.4 h1:f4pkN5PVSqlGxD2gZvboz6SRaeoykgknflMPBVuhcGs= @@ -162,6 +168,8 @@ github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.23.3 h1:gaq/4fd2/bQeJ33m4csgL7 github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.23.3/go.mod h1:vn+Rz9fAFGJtDXbBmYdTc71Q8iF/W/uK1/ec93hinD8= github.com/aws/aws-sdk-go-v2/service/eks v1.41.2 h1:0X5g5H8YyW9QVtlp6j+ZGHl/h0ZS58jiLRXabyiB5uw= github.com/aws/aws-sdk-go-v2/service/eks v1.41.2/go.mod h1:T2MBMUUCoSEvHuKPplubyQJbWNghbHhx3ToJpLoipDs= +github.com/aws/aws-sdk-go-v2/service/eks v1.53.0 h1:ACTxnLwL6YNmuYbxtp/VR3HGL9SWXU6VZkXPjWST9ZQ= +github.com/aws/aws-sdk-go-v2/service/eks v1.53.0/go.mod h1:ZzOjZXGGUQxOq+T3xmfPLKCZe4OaB5vm1LdGaC8IPn4= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1 h1:EyBZibRTVAs6ECHZOw5/wlylS9OcTzwyjeQMudmREjE= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1/go.mod h1:JKpmtYhhPs7D97NL/ltqz7yCkERFW5dOlHyVl66ZYF8= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.6 h1:b+E7zIUHMmcB4Dckjpkapoy47W6C9QBv/zoUP+Hn8Kc= @@ -180,6 +188,8 @@ github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw= github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM= github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= +github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20240318154307-a1a918375412 h1:tfbmGNeOidVXzO1I7zo/WsT5QX7Aa0BGTbnEAE4FG3E= github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20240318154307-a1a918375412/go.mod h1:kcUkjB9HwuV7PSck2b60kJtgDy+eTHWuAP0kb93FXsk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/kubetest2/internal/deployers/eksapi/cluster.go b/kubetest2/internal/deployers/eksapi/cluster.go index df48d9678..c5678e029 100644 --- a/kubetest2/internal/deployers/eksapi/cluster.go +++ b/kubetest2/internal/deployers/eksapi/cluster.go @@ -56,6 +56,25 @@ func (m *ClusterManager) getOrCreateCluster(infra *Infrastructure, opts *deploye }, Version: aws.String(opts.KubernetesVersion), } + if opts.AutoMode { + input.ComputeConfig = &ekstypes.ComputeConfigRequest{ + Enabled: aws.Bool(true), + NodePools: []string{"general-purpose", "system"}, + NodeRoleArn: &infra.nodeRole, + } + input.StorageConfig = &ekstypes.StorageConfigRequest{ + BlockStorage: &ekstypes.BlockStorage{ + Enabled: aws.Bool(true), + }, + } + input.KubernetesNetworkConfig.ElasticLoadBalancing = &ekstypes.ElasticLoadBalancing{ + Enabled: aws.Bool(true), + } + input.AccessConfig = &ekstypes.CreateAccessConfigRequest{ + AuthenticationMode: ekstypes.AuthenticationModeApi, + } + input.BootstrapSelfManagedAddons = aws.Bool(false) + } apiOpts, err := util.NewHTTPHeaderAPIOptions(opts.UpClusterHeaders) if err != nil { return nil, fmt.Errorf("failed to create API options: %v", err) diff --git a/kubetest2/internal/deployers/eksapi/deployer.go b/kubetest2/internal/deployers/eksapi/deployer.go index 8f69e60c3..c04d4754f 100644 --- a/kubetest2/internal/deployers/eksapi/deployer.go +++ b/kubetest2/internal/deployers/eksapi/deployer.go @@ -66,6 +66,7 @@ type deployerOptions struct { Addons []string `flag:"addons" desc:"Managed addons (name:version pairs) to create in the cluster. Use 'latest' for the most recent version, or 'default' for the default version."` AMI string `flag:"ami" desc:"AMI for unmanaged nodes"` AMIType string `flag:"ami-type" desc:"AMI type for managed nodes"` + AutoMode bool `flag:"auto-mode" desc:"Enable EKS Auto Mode"` CapacityReservation bool `flag:"capacity-reservation" desc:"Use capacity reservation for the unmanaged nodegroup"` ClusterRoleServicePrincipal string `flag:"cluster-role-service-principal" desc:"Additional service principal that can assume the cluster role"` EFA bool `flag:"efa" desc:"Create EFA interfaces on the node of an unmanaged nodegroup. Requires --unmanaged-nodes."` @@ -192,7 +193,7 @@ func (d *deployer) Up() error { if err != nil { return err } - if d.deployerOptions.StaticClusterName != "" { + if d.deployerOptions.StaticClusterName != "" || d.deployerOptions.AutoMode { klog.Infof("inited k8sclient, skip the rest resource creation for static cluster") if err := d.DeployBusyboxAndWaitForNodes(); err != nil { klog.Errorf("Failed to deploy Busybox pods: %v", err) diff --git a/kubetest2/internal/deployers/eksapi/templates/infra.yaml b/kubetest2/internal/deployers/eksapi/templates/infra.yaml index 007fd71ac..9da0777d8 100644 --- a/kubetest2/internal/deployers/eksapi/templates/infra.yaml +++ b/kubetest2/internal/deployers/eksapi/templates/infra.yaml @@ -41,7 +41,7 @@ Parameters: Subnet01AZ: Type: String - + Subnet02AZ: Type: String @@ -196,7 +196,7 @@ Resources: Type: AWS::EC2::Route DependsOn: - InternetGateway - - VPCGatewayAttachment + - VPCGatewayAttachment Properties: DestinationIpv6CidrBlock: ::/0 GatewayId: @@ -401,7 +401,9 @@ Resources: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - - Action: "sts:AssumeRole" + - Action: + - "sts:AssumeRole" + - "sts:TagSession" Effect: Allow Principal: Service: @@ -416,6 +418,26 @@ Resources: - - "arn:" - !Ref "AWS::Partition" - ":iam::aws:policy/AmazonEKSClusterPolicy" + - !Join + - "" + - - "arn:" + - !Ref "AWS::Partition" + - ":iam::aws:policy/AmazonEKSBlockStoragePolicy" + - !Join + - "" + - - "arn:" + - !Ref "AWS::Partition" + - ":iam::aws:policy/AmazonEKSComputePolicy" + - !Join + - "" + - - "arn:" + - !Ref "AWS::Partition" + - ":iam::aws:policy/AmazonEKSLoadBalancingPolicy" + - !Join + - "" + - - "arn:" + - !Ref "AWS::Partition" + - ":iam::aws:policy/AmazonEKSNetworkingPolicy" NodeRole: Type: AWS::IAM::Role