Skip to content

Commit 53a9c82

Browse files
✨ Add ability to control "EKS Auto Mode" for EKS clusters
Signed-off-by: Siarhei Rasiukevich <s.rasiukevich@gmail.com>
1 parent cfdcb14 commit 53a9c82

12 files changed

+1289
-207
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func TestDefaultingWebhook(t *testing.T) {
9292
NetworkSpec: defaultNetworkSpec,
9393
TokenMethod: &EKSTokenMethodIAMAuthenticator,
9494
BootstrapSelfManagedAddons: true,
95+
EKSAutoMode: true,
9596
},
9697
},
9798
{
@@ -106,6 +107,7 @@ func TestDefaultingWebhook(t *testing.T) {
106107
NetworkSpec: defaultNetworkSpec,
107108
TokenMethod: &EKSTokenMethodIAMAuthenticator,
108109
BootstrapSelfManagedAddons: true,
110+
EKSAutoMode: true,
109111
},
110112
},
111113
{
@@ -120,6 +122,7 @@ func TestDefaultingWebhook(t *testing.T) {
120122
NetworkSpec: defaultNetworkSpec,
121123
TokenMethod: &EKSTokenMethodIAMAuthenticator,
122124
BootstrapSelfManagedAddons: true,
125+
EKSAutoMode: true,
123126
},
124127
},
125128
{
@@ -138,6 +141,7 @@ func TestDefaultingWebhook(t *testing.T) {
138141
NetworkSpec: defaultNetworkSpec,
139142
TokenMethod: &EKSTokenMethodIAMAuthenticator,
140143
BootstrapSelfManagedAddons: true,
144+
EKSAutoMode: true,
141145
},
142146
},
143147
{
@@ -159,6 +163,7 @@ func TestDefaultingWebhook(t *testing.T) {
159163
NetworkSpec: defaultNetworkSpec,
160164
TokenMethod: &EKSTokenMethodIAMAuthenticator,
161165
BootstrapSelfManagedAddons: true,
166+
EKSAutoMode: true,
162167
},
163168
},
164169
{
@@ -181,6 +186,7 @@ func TestDefaultingWebhook(t *testing.T) {
181186
},
182187
TokenMethod: &EKSTokenMethodIAMAuthenticator,
183188
BootstrapSelfManagedAddons: true,
189+
EKSAutoMode: true,
184190
},
185191
},
186192
{
@@ -196,6 +202,7 @@ func TestDefaultingWebhook(t *testing.T) {
196202
SecondaryCidrBlock: nil,
197203
TokenMethod: &EKSTokenMethodIAMAuthenticator,
198204
BootstrapSelfManagedAddons: true,
205+
EKSAutoMode: 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)