From 7e4ed51e5224c03a92073f1a17a6dda9640180d5 Mon Sep 17 00:00:00 2001 From: Jaswanth Veerapaneni Date: Wed, 20 Nov 2024 13:22:53 -0500 Subject: [PATCH] Add bootstrap self managed addons flag to eks controlplane spec --- ...trolplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml | 7 +++++++ controlplane/eks/api/v1beta1/conversion.go | 1 + controlplane/eks/api/v1beta1/zz_generated.conversion.go | 1 + .../eks/api/v1beta2/awsmanagedcontrolplane_types.go | 6 ++++++ pkg/cloud/scope/managedcontrolplane.go | 5 +++++ pkg/cloud/services/eks/cluster.go | 5 +++++ 6 files changed, 25 insertions(+) diff --git a/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml b/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml index af854b225e..01c1563547 100644 --- a/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml +++ b/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml @@ -2198,6 +2198,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. diff --git a/controlplane/eks/api/v1beta1/conversion.go b/controlplane/eks/api/v1beta1/conversion.go index e137e7dede..f44e52d954 100644 --- a/controlplane/eks/api/v1beta1/conversion.go +++ b/controlplane/eks/api/v1beta1/conversion.go @@ -41,6 +41,7 @@ func (r *AWSManagedControlPlane) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.VpcCni.Disable = r.Spec.DisableVPCCNI dst.Spec.Partition = restored.Spec.Partition dst.Spec.RestrictPrivateSubnets = restored.Spec.RestrictPrivateSubnets + dst.Spec.BootstrapSelfManagedAddons = restored.Spec.BootstrapSelfManagedAddons return nil } diff --git a/controlplane/eks/api/v1beta1/zz_generated.conversion.go b/controlplane/eks/api/v1beta1/zz_generated.conversion.go index 481943f7bd..266fcd71d0 100644 --- a/controlplane/eks/api/v1beta1/zz_generated.conversion.go +++ b/controlplane/eks/api/v1beta1/zz_generated.conversion.go @@ -403,6 +403,7 @@ func autoConvert_v1beta2_AWSManagedControlPlaneSpec_To_v1beta1_AWSManagedControl if err := Convert_v1beta2_VpcCni_To_v1beta1_VpcCni(&in.VpcCni, &out.VpcCni, s); err != nil { return err } + // WARNING: in.BootstrapSelfManagedAddons requires manual conversion: does not exist in peer-type // WARNING: in.RestrictPrivateSubnets requires manual conversion: does not exist in peer-type if err := Convert_v1beta2_KubeProxy_To_v1beta1_KubeProxy(&in.KubeProxy, &out.KubeProxy, s); err != nil { return err diff --git a/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_types.go b/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_types.go index 109752e573..7dc51a21ef 100644 --- a/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_types.go +++ b/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_types.go @@ -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"` diff --git a/pkg/cloud/scope/managedcontrolplane.go b/pkg/cloud/scope/managedcontrolplane.go index 14ded92263..5f8b9cd938 100644 --- a/pkg/cloud/scope/managedcontrolplane.go +++ b/pkg/cloud/scope/managedcontrolplane.go @@ -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 diff --git a/pkg/cloud/services/eks/cluster.go b/pkg/cloud/services/eks/cluster.go index 62c990bd36..255182d5aa 100644 --- a/pkg/cloud/services/eks/cluster.go +++ b/pkg/cloud/services/eks/cluster.go @@ -422,6 +422,11 @@ func (s *Service) createCluster(eksClusterName string) (*eks.Cluster, error) { Tags: tags, KubernetesNetworkConfig: netConfig, } + // Outside of input since we want to set it only when BootstrapSelfManagedAddons set to false. + // Default is true. + if !s.scope.ControlPlane.Spec.BootstrapSelfManagedAddons { + input.BootstrapSelfManagedAddons = &s.scope.ControlPlane.Spec.BootstrapSelfManagedAddons + } var out *eks.CreateClusterOutput if err := wait.WaitForWithRetryable(wait.NewBackoff(), func() (bool, error) {