Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2194,6 +2194,13 @@ spec:
will be the default.
type: string
type: object
bootstrapSelfManagedAddons:
default: true
description: |-
BootstrapSelfManagedAddons is used to set configuration options for
bare EKS cluster without EKS default networking addons
If you set this value to false when creating a cluster, the default networking add-ons will not be installed
type: boolean
controlPlaneEndpoint:
description: ControlPlaneEndpoint represents the endpoint used to
communicate with the control plane.
Expand Down
2 changes: 1 addition & 1 deletion controlplane/eks/api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (r *AWSManagedControlPlane) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.Partition = restored.Spec.Partition
dst.Spec.RestrictPrivateSubnets = restored.Spec.RestrictPrivateSubnets
dst.Status.Version = restored.Status.Version

dst.Spec.BootstrapSelfManagedAddons = restored.Spec.BootstrapSelfManagedAddons
return nil
}

Expand Down
1 change: 1 addition & 0 deletions controlplane/eks/api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions controlplane/eks/api/v1beta2/awsmanagedcontrolplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned
// +optional
VpcCni VpcCni `json:"vpcCni,omitempty"`

// BootstrapSelfManagedAddons is used to set configuration options for
// bare EKS cluster without EKS default networking addons
// If you set this value to false when creating a cluster, the default networking add-ons will not be installed
// +kubebuilder:default=true
BootstrapSelfManagedAddons bool `json:"bootstrapSelfManagedAddons,omitempty"`

// RestrictPrivateSubnets indicates that the EKS control plane should only use private subnets.
// +kubebuilder:default=false
RestrictPrivateSubnets bool `json:"restrictPrivateSubnets,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,4 +502,7 @@ func (r *AWSManagedControlPlane) Default() {

infrav1.SetDefaults_Bastion(&r.Spec.Bastion)
infrav1.SetDefaults_NetworkSpec(&r.Spec.NetworkSpec)

// Set default value for BootstrapSelfManagedAddons
r.Spec.BootstrapSelfManagedAddons = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,52 +85,52 @@ func TestDefaultingWebhook(t *testing.T) {
resourceName: "cluster1",
resourceNS: "default",
expectHash: false,
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
},
{
name: "less than 100 chars, dot in name",
resourceName: "team1.cluster1",
resourceNS: "default",
expectHash: false,
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_team1_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_team1_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
},
{
name: "more than 100 chars",
resourceName: "abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde",
resourceNS: "default",
expectHash: true,
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "capi_", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "capi_", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
},
{
name: "with patch",
resourceName: "cluster1",
resourceNS: "default",
expectHash: false,
spec: AWSManagedControlPlaneSpec{Version: &vV1_17_1},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", Version: &vV1_17_1, IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", Version: &vV1_17_1, IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
},
{
name: "with allowed ip on bastion",
resourceName: "cluster1",
resourceNS: "default",
expectHash: false,
spec: AWSManagedControlPlaneSpec{Bastion: infrav1.Bastion{AllowedCIDRBlocks: []string{"100.100.100.100/0"}}},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: infrav1.Bastion{AllowedCIDRBlocks: []string{"100.100.100.100/0"}}, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: infrav1.Bastion{AllowedCIDRBlocks: []string{"100.100.100.100/0"}}, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
},
{
name: "with CNI on network",
resourceName: "cluster1",
resourceNS: "default",
expectHash: false,
spec: AWSManagedControlPlaneSpec{NetworkSpec: infrav1.NetworkSpec{CNI: &infrav1.CNISpec{}}},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: infrav1.NetworkSpec{CNI: &infrav1.CNISpec{}, VPC: defaultVPCSpec}, TokenMethod: &EKSTokenMethodIAMAuthenticator},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: infrav1.NetworkSpec{CNI: &infrav1.CNISpec{}, VPC: defaultVPCSpec}, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
},
{
name: "secondary CIDR",
resourceName: "cluster1",
resourceNS: "default",
expectHash: false,
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, SecondaryCidrBlock: nil, TokenMethod: &EKSTokenMethodIAMAuthenticator},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, SecondaryCidrBlock: nil, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
},
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/cloud/scope/managedcontrolplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,11 @@ func (s *ManagedControlPlaneScope) DisableVPCCNI() bool {
return s.ControlPlane.Spec.VpcCni.Disable
}

// BootstrapSelfManagedAddons returns whether the AWS EKS networking addons should be disabled.
func (s *ManagedControlPlaneScope) BootstrapSelfManagedAddons() bool {
return s.ControlPlane.Spec.BootstrapSelfManagedAddons
}

// VpcCni returns a list of environment variables to apply to the `aws-node` DaemonSet.
func (s *ManagedControlPlaneScope) VpcCni() ekscontrolplanev1.VpcCni {
return s.ControlPlane.Spec.VpcCni
Expand Down
5 changes: 5 additions & 0 deletions pkg/cloud/services/eks/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,11 @@ func (s *Service) createCluster(eksClusterName string) (*eks.Cluster, error) {
Tags: tags,
KubernetesNetworkConfig: netConfig,
}
// Only set BootstrapSelfManagedAddons if it's explicitly set to false in the spec
// Default is true, so we don't need to set it in that case
if !s.scope.BootstrapSelfManagedAddons() {
input.BootstrapSelfManagedAddons = aws.Bool(false)
}

var out *eks.CreateClusterOutput
if err := wait.WaitForWithRetryable(wait.NewBackoff(), func() (bool, error) {
Expand Down
20 changes: 12 additions & 8 deletions pkg/cloud/services/eks/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,11 @@ func TestCreateCluster(t *testing.T) {
},
ControlPlane: &ekscontrolplanev1.AWSManagedControlPlane{
Spec: ekscontrolplanev1.AWSManagedControlPlaneSpec{
EKSClusterName: clusterName,
Version: version,
RoleName: tc.role,
NetworkSpec: infrav1.NetworkSpec{Subnets: tc.subnets},
EKSClusterName: clusterName,
Version: version,
RoleName: tc.role,
NetworkSpec: infrav1.NetworkSpec{Subnets: tc.subnets},
BootstrapSelfManagedAddons: false,
},
},
})
Expand All @@ -541,9 +542,10 @@ func TestCreateCluster(t *testing.T) {
ResourcesVpcConfig: &eks.VpcConfigRequest{
SubnetIds: subnetIDs,
},
RoleArn: tc.role,
Tags: tc.tags,
Version: version,
RoleArn: tc.role,
Tags: tc.tags,
Version: version,
BootstrapSelfManagedAddons: aws.Bool(false),
}).Return(&eks.CreateClusterOutput{}, nil)
}
s := NewService(scope)
Expand Down Expand Up @@ -728,7 +730,8 @@ func TestCreateIPv6Cluster(t *testing.T) {
},
VPC: vpcSpec,
},
EncryptionConfig: encryptionConfig,
EncryptionConfig: encryptionConfig,
BootstrapSelfManagedAddons: false,
},
},
})
Expand All @@ -754,6 +757,7 @@ func TestCreateIPv6Cluster(t *testing.T) {
Tags: map[string]*string{
"kubernetes.io/cluster/cluster-name": ptr.To[string]("owned"),
},
BootstrapSelfManagedAddons: aws.Bool(false),
}).Return(&eks.CreateClusterOutput{}, nil)
iamMock.EXPECT().GetRole(&iam.GetRoleInput{
RoleName: aws.String("arn-role"),
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/data/e2e_eks_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ providers:
targetName: "cluster-template-eks-ipv6-cluster.yaml"
- sourcePath: "./eks/cluster-template-eks-control-plane-only-legacy.yaml"
targetName: "cluster-template-eks-control-plane-only-legacy.yaml"
- sourcePath: "./eks/cluster-template-eks-control-plane-bare-eks.yaml"
targetName: "cluster-template-eks-control-plane-bare-eks.yaml"

variables:
KUBERNETES_VERSION: "v1.31.0"
Expand Down
36 changes: 36 additions & 0 deletions test/e2e/data/eks/cluster-template-eks-control-plane-bare-eks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: "${CLUSTER_NAME}"
spec:
clusterNetwork:
pods:
cidrBlocks: ["192.168.0.0/16"]
infrastructureRef:
kind: AWSManagedCluster
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
name: "${CLUSTER_NAME}"
controlPlaneRef:
kind: AWSManagedControlPlane
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
name: "${CLUSTER_NAME}-control-plane"
---
kind: AWSManagedCluster
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
metadata:
name: "${CLUSTER_NAME}"
spec: {}
---
kind: AWSManagedControlPlane
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
metadata:
name: "${CLUSTER_NAME}-control-plane"
spec:
region: "${AWS_REGION}"
sshKeyName: "${AWS_SSH_KEY_NAME}"
version: "${KUBERNETES_VERSION}"
identityRef:
kind: AWSClusterStaticIdentity
name: e2e-account
bootstrapSelfManagedAddons: false