Skip to content

Commit 6867e42

Browse files
✨ Add ability to control "EKS Auto Mode" for EKS clusters
Signed-off-by: Siarhei Rasiukevich <[email protected]>
1 parent cfdcb14 commit 6867e42

12 files changed

+1296
-214
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,15 @@ spec:
23432343
- host
23442344
- port
23452345
type: object
2346+
eksAutoMode:
2347+
default: true
2348+
description: |-
2349+
EKSAutoMode indicates the EKS Auto Mode state for control-plane.
2350+
If you set this value to false, the following params will be disabled for EKS:
2351+
AWS::EKS::Cluster KubernetesNetworkConfig ElasticLoadBalancing Enabled -> false.
2352+
AWS::EKS::Cluster StorageConfig blockStorage Enabled -> false.
2353+
AWS::EKS::Cluster ComputeConfig Enabled -> false.
2354+
type: boolean
23462355
eksClusterName:
23472356
description: |-
23482357
EKSClusterName allows you to specify the name of the EKS cluster in
@@ -3329,6 +3338,8 @@ spec:
33293338
type: object
33303339
type: array
33313340
type: object
3341+
required:
3342+
- eksAutoMode
33323343
type: object
33333344
status:
33343345
description: AWSManagedControlPlaneStatus defines the observed state of

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ spec:
160160
- host
161161
- port
162162
type: object
163+
eksAutoMode:
164+
default: true
165+
description: |-
166+
EKSAutoMode indicates the EKS Auto Mode state for control-plane.
167+
If you set this value to false, the following params will be disabled for EKS:
168+
AWS::EKS::Cluster KubernetesNetworkConfig ElasticLoadBalancing Enabled -> false.
169+
AWS::EKS::Cluster StorageConfig blockStorage Enabled -> false.
170+
AWS::EKS::Cluster ComputeConfig Enabled -> false.
171+
type: boolean
163172
eksClusterName:
164173
description: |-
165174
EKSClusterName allows you to specify the name of the EKS cluster in
@@ -1161,6 +1170,8 @@ spec:
11611170
type: object
11621171
type: array
11631172
type: object
1173+
required:
1174+
- eksAutoMode
11641175
type: object
11651176
required:
11661177
- spec

controlplane/eks/api/v1beta1/conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ func (r *AWSManagedControlPlane) ConvertTo(dstRaw conversion.Hub) error {
121121
dst.Spec.RolePermissionsBoundary = restored.Spec.RolePermissionsBoundary
122122
dst.Status.Version = restored.Status.Version
123123
dst.Spec.BootstrapSelfManagedAddons = restored.Spec.BootstrapSelfManagedAddons
124+
dst.Spec.EKSAutoMode = restored.Spec.EKSAutoMode
124125
return nil
125126
}
126127

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,15 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned
200200
// bare EKS cluster without EKS default networking addons
201201
// If you set this value to false when creating a cluster, the default networking add-ons will not be installed
202202
// +kubebuilder:default=true
203-
BootstrapSelfManagedAddons bool `json:"bootstrapSelfManagedAddons,omitempty"`
203+
BootstrapSelfManagedAddons *bool `json:"bootstrapSelfManagedAddons,omitempty"`
204+
205+
// EKSAutoMode indicates the EKS Auto Mode state for control-plane.
206+
// If you set this value to false, the following params will be disabled for EKS:
207+
// AWS::EKS::Cluster KubernetesNetworkConfig ElasticLoadBalancing Enabled -> false.
208+
// AWS::EKS::Cluster StorageConfig blockStorage Enabled -> false.
209+
// AWS::EKS::Cluster ComputeConfig Enabled -> false.
210+
// +kubebuilder:default=true
211+
EKSAutoMode *bool `json:"eksAutoMode"`
204212

205213
// RestrictPrivateSubnets indicates that the EKS control plane should only use private subnets.
206214
// +kubebuilder:default=false

controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1beta2
1919
import (
2020
"context"
2121
"fmt"
22+
"github.com/aws/aws-sdk-go-v2/aws"
2223
"net"
2324

2425
"github.com/apparentlymart/go-cidr/cidr"
@@ -572,6 +573,13 @@ func (*awsManagedControlPlaneWebhook) Default(_ context.Context, obj runtime.Obj
572573
infrav1.SetDefaults_NetworkSpec(&r.Spec.NetworkSpec)
573574

574575
// Set default value for BootstrapSelfManagedAddons
575-
r.Spec.BootstrapSelfManagedAddons = true
576+
if r.Spec.BootstrapSelfManagedAddons == nil {
577+
r.Spec.BootstrapSelfManagedAddons = aws.Bool(true)
578+
}
579+
580+
// Set default value for EKSAutoMode
581+
if r.Spec.EKSAutoMode == nil {
582+
r.Spec.EKSAutoMode = aws.Bool(true)
583+
}
576584
return nil
577585
}

controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook_test.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ func TestDefaultingWebhook(t *testing.T) {
9191
Bastion: defaultTestBastion,
9292
NetworkSpec: defaultNetworkSpec,
9393
TokenMethod: &EKSTokenMethodIAMAuthenticator,
94-
BootstrapSelfManagedAddons: true,
94+
BootstrapSelfManagedAddons: aws.Bool(true),
95+
EKSAutoMode: aws.Bool(true),
9596
},
9697
},
9798
{
@@ -105,7 +106,8 @@ func TestDefaultingWebhook(t *testing.T) {
105106
Bastion: defaultTestBastion,
106107
NetworkSpec: defaultNetworkSpec,
107108
TokenMethod: &EKSTokenMethodIAMAuthenticator,
108-
BootstrapSelfManagedAddons: true,
109+
BootstrapSelfManagedAddons: aws.Bool(true),
110+
EKSAutoMode: aws.Bool(true),
109111
},
110112
},
111113
{
@@ -119,7 +121,8 @@ func TestDefaultingWebhook(t *testing.T) {
119121
Bastion: defaultTestBastion,
120122
NetworkSpec: defaultNetworkSpec,
121123
TokenMethod: &EKSTokenMethodIAMAuthenticator,
122-
BootstrapSelfManagedAddons: true,
124+
BootstrapSelfManagedAddons: aws.Bool(true),
125+
EKSAutoMode: aws.Bool(true),
123126
},
124127
},
125128
{
@@ -137,7 +140,8 @@ func TestDefaultingWebhook(t *testing.T) {
137140
Bastion: defaultTestBastion,
138141
NetworkSpec: defaultNetworkSpec,
139142
TokenMethod: &EKSTokenMethodIAMAuthenticator,
140-
BootstrapSelfManagedAddons: true,
143+
BootstrapSelfManagedAddons: aws.Bool(true),
144+
EKSAutoMode: aws.Bool(true),
141145
},
142146
},
143147
{
@@ -158,7 +162,8 @@ func TestDefaultingWebhook(t *testing.T) {
158162
},
159163
NetworkSpec: defaultNetworkSpec,
160164
TokenMethod: &EKSTokenMethodIAMAuthenticator,
161-
BootstrapSelfManagedAddons: true,
165+
BootstrapSelfManagedAddons: aws.Bool(true),
166+
EKSAutoMode: aws.Bool(true),
162167
},
163168
},
164169
{
@@ -180,7 +185,8 @@ func TestDefaultingWebhook(t *testing.T) {
180185
VPC: defaultVPCSpec,
181186
},
182187
TokenMethod: &EKSTokenMethodIAMAuthenticator,
183-
BootstrapSelfManagedAddons: true,
188+
BootstrapSelfManagedAddons: aws.Bool(true),
189+
EKSAutoMode: aws.Bool(true),
184190
},
185191
},
186192
{
@@ -195,7 +201,8 @@ func TestDefaultingWebhook(t *testing.T) {
195201
NetworkSpec: defaultNetworkSpec,
196202
SecondaryCidrBlock: nil,
197203
TokenMethod: &EKSTokenMethodIAMAuthenticator,
198-
BootstrapSelfManagedAddons: true,
204+
BootstrapSelfManagedAddons: aws.Bool(true),
205+
EKSAutoMode: aws.Bool(true),
199206
},
200207
},
201208
}

controlplane/eks/api/v1beta2/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)