Skip to content

Commit 49ba275

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

12 files changed

+1289
-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
@@ -2353,6 +2353,15 @@ spec:
23532353
- host
23542354
- port
23552355
type: object
2356+
eksAutoMode:
2357+
default: true
2358+
description: |-
2359+
EKSAutoMode indicates the EKS Auto Mode state for control-plane.
2360+
If you set this value to false, the following params will be disabled for EKS:
2361+
AWS::EKS::Cluster KubernetesNetworkConfig ElasticLoadBalancing Enabled -> false.
2362+
AWS::EKS::Cluster StorageConfig blockStorage Enabled -> false.
2363+
AWS::EKS::Cluster ComputeConfig Enabled -> false.
2364+
type: boolean
23562365
eksClusterName:
23572366
description: |-
23582367
EKSClusterName allows you to specify the name of the EKS cluster in
@@ -3339,6 +3348,8 @@ spec:
33393348
type: object
33403349
type: array
33413350
type: object
3351+
required:
3352+
- eksAutoMode
33423353
type: object
33433354
status:
33443355
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
@@ -165,6 +165,15 @@ spec:
165165
- host
166166
- port
167167
type: object
168+
eksAutoMode:
169+
default: true
170+
description: |-
171+
EKSAutoMode indicates the EKS Auto Mode state for control-plane.
172+
If you set this value to false, the following params will be disabled for EKS:
173+
AWS::EKS::Cluster KubernetesNetworkConfig ElasticLoadBalancing Enabled -> false.
174+
AWS::EKS::Cluster StorageConfig blockStorage Enabled -> false.
175+
AWS::EKS::Cluster ComputeConfig Enabled -> false.
176+
type: boolean
168177
eksClusterName:
169178
description: |-
170179
EKSClusterName allows you to specify the name of the EKS cluster in
@@ -1166,6 +1175,8 @@ spec:
11661175
type: object
11671176
type: array
11681177
type: object
1178+
required:
1179+
- eksAutoMode
11691180
type: object
11701181
required:
11711182
- 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 & 7 deletions
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, BootstrapSelfManagedAddons: true},
88+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: aws.Bool(true), EKSAutoMode: aws.Bool(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, BootstrapSelfManagedAddons: true},
95+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_team1_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: aws.Bool(true), EKSAutoMode: aws.Bool(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, BootstrapSelfManagedAddons: true},
102+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "capi_", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: aws.Bool(true), EKSAutoMode: aws.Bool(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, BootstrapSelfManagedAddons: true},
110+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", Version: &vV1_17_1, IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: aws.Bool(true), EKSAutoMode: aws.Bool(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, BootstrapSelfManagedAddons: true},
118+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: infrav1.Bastion{AllowedCIDRBlocks: []string{"100.100.100.100/0"}}, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: aws.Bool(true), EKSAutoMode: aws.Bool(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, BootstrapSelfManagedAddons: true},
126+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: infrav1.NetworkSpec{CNI: &infrav1.CNISpec{}, VPC: defaultVPCSpec}, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: aws.Bool(true), EKSAutoMode: aws.Bool(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, BootstrapSelfManagedAddons: true},
133+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, SecondaryCidrBlock: nil, TokenMethod: &EKSTokenMethodIAMAuthenticator, BootstrapSelfManagedAddons: aws.Bool(true), EKSAutoMode: aws.Bool(true)},
134134
},
135135
}
136136

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)