Skip to content

Commit e4961f8

Browse files
authored
Merge pull request #5222 from jas-nik/bare-eks
✨ Support for BoostrapSelfManagedAddons flag for EKS cluster creation
2 parents c1764a9 + 1bef3c6 commit e4961f8

11 files changed

+85
-16
lines changed

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -2194,6 +2194,13 @@ spec:
21942194
will be the default.
21952195
type: string
21962196
type: object
2197+
bootstrapSelfManagedAddons:
2198+
default: true
2199+
description: |-
2200+
BootstrapSelfManagedAddons is used to set configuration options for
2201+
bare EKS cluster without EKS default networking addons
2202+
If you set this value to false when creating a cluster, the default networking add-ons will not be installed
2203+
type: boolean
21972204
controlPlaneEndpoint:
21982205
description: ControlPlaneEndpoint represents the endpoint used to
21992206
communicate with the control plane.

controlplane/eks/api/v1beta1/conversion.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (r *AWSManagedControlPlane) ConvertTo(dstRaw conversion.Hub) error {
4343
dst.Spec.Partition = restored.Spec.Partition
4444
dst.Spec.RestrictPrivateSubnets = restored.Spec.RestrictPrivateSubnets
4545
dst.Status.Version = restored.Status.Version
46-
46+
dst.Spec.BootstrapSelfManagedAddons = restored.Spec.BootstrapSelfManagedAddons
4747
return nil
4848
}
4949

controlplane/eks/api/v1beta1/zz_generated.conversion.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/eks/api/v1beta2/awsmanagedcontrolplane_types.go

+6
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned
173173
// +optional
174174
VpcCni VpcCni `json:"vpcCni,omitempty"`
175175

176+
// BootstrapSelfManagedAddons is used to set configuration options for
177+
// bare EKS cluster without EKS default networking addons
178+
// If you set this value to false when creating a cluster, the default networking add-ons will not be installed
179+
// +kubebuilder:default=true
180+
BootstrapSelfManagedAddons bool `json:"bootstrapSelfManagedAddons,omitempty"`
181+
176182
// RestrictPrivateSubnets indicates that the EKS control plane should only use private subnets.
177183
// +kubebuilder:default=false
178184
RestrictPrivateSubnets bool `json:"restrictPrivateSubnets,omitempty"`

controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go

+3
Original file line numberDiff line numberDiff line change
@@ -502,4 +502,7 @@ func (r *AWSManagedControlPlane) Default() {
502502

503503
infrav1.SetDefaults_Bastion(&r.Spec.Bastion)
504504
infrav1.SetDefaults_NetworkSpec(&r.Spec.NetworkSpec)
505+
506+
// Set default value for BootstrapSelfManagedAddons
507+
r.Spec.BootstrapSelfManagedAddons = true
505508
}

controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -85,52 +85,52 @@ func TestDefaultingWebhook(t *testing.T) {
8585
resourceName: "cluster1",
8686
resourceNS: "default",
8787
expectHash: false,
88-
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
88+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
8989
},
9090
{
9191
name: "less than 100 chars, dot in name",
9292
resourceName: "team1.cluster1",
9393
resourceNS: "default",
9494
expectHash: false,
95-
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_team1_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
95+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_team1_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
9696
},
9797
{
9898
name: "more than 100 chars",
9999
resourceName: "abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde",
100100
resourceNS: "default",
101101
expectHash: true,
102-
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "capi_", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
102+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "capi_", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
103103
},
104104
{
105105
name: "with patch",
106106
resourceName: "cluster1",
107107
resourceNS: "default",
108108
expectHash: false,
109109
spec: AWSManagedControlPlaneSpec{Version: &vV1_17_1},
110-
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", Version: &vV1_17_1, IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
110+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", Version: &vV1_17_1, IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
111111
},
112112
{
113113
name: "with allowed ip on bastion",
114114
resourceName: "cluster1",
115115
resourceNS: "default",
116116
expectHash: false,
117117
spec: AWSManagedControlPlaneSpec{Bastion: infrav1.Bastion{AllowedCIDRBlocks: []string{"100.100.100.100/0"}}},
118-
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: infrav1.Bastion{AllowedCIDRBlocks: []string{"100.100.100.100/0"}}, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
118+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: infrav1.Bastion{AllowedCIDRBlocks: []string{"100.100.100.100/0"}}, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
119119
},
120120
{
121121
name: "with CNI on network",
122122
resourceName: "cluster1",
123123
resourceNS: "default",
124124
expectHash: false,
125125
spec: AWSManagedControlPlaneSpec{NetworkSpec: infrav1.NetworkSpec{CNI: &infrav1.CNISpec{}}},
126-
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: infrav1.NetworkSpec{CNI: &infrav1.CNISpec{}, VPC: defaultVPCSpec}, TokenMethod: &EKSTokenMethodIAMAuthenticator},
126+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: infrav1.NetworkSpec{CNI: &infrav1.CNISpec{}, VPC: defaultVPCSpec}, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
127127
},
128128
{
129129
name: "secondary CIDR",
130130
resourceName: "cluster1",
131131
resourceNS: "default",
132132
expectHash: false,
133-
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, SecondaryCidrBlock: nil, TokenMethod: &EKSTokenMethodIAMAuthenticator},
133+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, SecondaryCidrBlock: nil, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: true},
134134
},
135135
}
136136

pkg/cloud/scope/managedcontrolplane.go

+5
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ func (s *ManagedControlPlaneScope) DisableVPCCNI() bool {
424424
return s.ControlPlane.Spec.VpcCni.Disable
425425
}
426426

427+
// BootstrapSelfManagedAddons returns whether the AWS EKS networking addons should be disabled.
428+
func (s *ManagedControlPlaneScope) BootstrapSelfManagedAddons() bool {
429+
return s.ControlPlane.Spec.BootstrapSelfManagedAddons
430+
}
431+
427432
// VpcCni returns a list of environment variables to apply to the `aws-node` DaemonSet.
428433
func (s *ManagedControlPlaneScope) VpcCni() ekscontrolplanev1.VpcCni {
429434
return s.ControlPlane.Spec.VpcCni

pkg/cloud/services/eks/cluster.go

+5
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,11 @@ func (s *Service) createCluster(eksClusterName string) (*eks.Cluster, error) {
473473
Tags: tags,
474474
KubernetesNetworkConfig: netConfig,
475475
}
476+
// Only set BootstrapSelfManagedAddons if it's explicitly set to false in the spec
477+
// Default is true, so we don't need to set it in that case
478+
if !s.scope.BootstrapSelfManagedAddons() {
479+
input.BootstrapSelfManagedAddons = aws.Bool(false)
480+
}
476481

477482
var out *eks.CreateClusterOutput
478483
if err := wait.WaitForWithRetryable(wait.NewBackoff(), func() (bool, error) {

pkg/cloud/services/eks/cluster_test.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,11 @@ func TestCreateCluster(t *testing.T) {
519519
},
520520
ControlPlane: &ekscontrolplanev1.AWSManagedControlPlane{
521521
Spec: ekscontrolplanev1.AWSManagedControlPlaneSpec{
522-
EKSClusterName: clusterName,
523-
Version: version,
524-
RoleName: tc.role,
525-
NetworkSpec: infrav1.NetworkSpec{Subnets: tc.subnets},
522+
EKSClusterName: clusterName,
523+
Version: version,
524+
RoleName: tc.role,
525+
NetworkSpec: infrav1.NetworkSpec{Subnets: tc.subnets},
526+
BootstrapSelfManagedAddons: false,
526527
},
527528
},
528529
})
@@ -541,9 +542,10 @@ func TestCreateCluster(t *testing.T) {
541542
ResourcesVpcConfig: &eks.VpcConfigRequest{
542543
SubnetIds: subnetIDs,
543544
},
544-
RoleArn: tc.role,
545-
Tags: tc.tags,
546-
Version: version,
545+
RoleArn: tc.role,
546+
Tags: tc.tags,
547+
Version: version,
548+
BootstrapSelfManagedAddons: aws.Bool(false),
547549
}).Return(&eks.CreateClusterOutput{}, nil)
548550
}
549551
s := NewService(scope)
@@ -728,7 +730,8 @@ func TestCreateIPv6Cluster(t *testing.T) {
728730
},
729731
VPC: vpcSpec,
730732
},
731-
EncryptionConfig: encryptionConfig,
733+
EncryptionConfig: encryptionConfig,
734+
BootstrapSelfManagedAddons: false,
732735
},
733736
},
734737
})
@@ -754,6 +757,7 @@ func TestCreateIPv6Cluster(t *testing.T) {
754757
Tags: map[string]*string{
755758
"kubernetes.io/cluster/cluster-name": ptr.To[string]("owned"),
756759
},
760+
BootstrapSelfManagedAddons: aws.Bool(false),
757761
}).Return(&eks.CreateClusterOutput{}, nil)
758762
iamMock.EXPECT().GetRole(&iam.GetRoleInput{
759763
RoleName: aws.String("arn-role"),

test/e2e/data/e2e_eks_conf.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ providers:
114114
targetName: "cluster-template-eks-ipv6-cluster.yaml"
115115
- sourcePath: "./eks/cluster-template-eks-control-plane-only-legacy.yaml"
116116
targetName: "cluster-template-eks-control-plane-only-legacy.yaml"
117+
- sourcePath: "./eks/cluster-template-eks-control-plane-bare-eks.yaml"
118+
targetName: "cluster-template-eks-control-plane-bare-eks.yaml"
117119

118120
variables:
119121
KUBERNETES_VERSION: "v1.31.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: Cluster
4+
metadata:
5+
name: "${CLUSTER_NAME}"
6+
spec:
7+
clusterNetwork:
8+
pods:
9+
cidrBlocks: ["192.168.0.0/16"]
10+
infrastructureRef:
11+
kind: AWSManagedCluster
12+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
13+
name: "${CLUSTER_NAME}"
14+
controlPlaneRef:
15+
kind: AWSManagedControlPlane
16+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
17+
name: "${CLUSTER_NAME}-control-plane"
18+
---
19+
kind: AWSManagedCluster
20+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
21+
metadata:
22+
name: "${CLUSTER_NAME}"
23+
spec: {}
24+
---
25+
kind: AWSManagedControlPlane
26+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
27+
metadata:
28+
name: "${CLUSTER_NAME}-control-plane"
29+
spec:
30+
region: "${AWS_REGION}"
31+
sshKeyName: "${AWS_SSH_KEY_NAME}"
32+
version: "${KUBERNETES_VERSION}"
33+
identityRef:
34+
kind: AWSClusterStaticIdentity
35+
name: e2e-account
36+
bootstrapSelfManagedAddons: false

0 commit comments

Comments
 (0)