From 6431ec6d686e28f0b92c2c84b8b87b55f53a5308 Mon Sep 17 00:00:00 2001 From: edibble21 <85638465+edibble21@users.noreply.github.com> Date: Thu, 14 Nov 2024 21:26:25 -0800 Subject: [PATCH] Add Cluster CIDR setting for bottlerocket --- pkg/providers/amifamily/bootstrap/bottlerocket.go | 1 + pkg/providers/amifamily/bootstrap/bottlerocketsettings.go | 1 + pkg/providers/amifamily/bottlerocket.go | 1 + pkg/providers/launchtemplate/testdata/br_userdata_merged.golden | 1 + .../launchtemplate/testdata/br_userdata_unmerged.golden | 1 + 5 files changed, 5 insertions(+) diff --git a/pkg/providers/amifamily/bootstrap/bottlerocket.go b/pkg/providers/amifamily/bootstrap/bottlerocket.go index 9dfa60042ce1..3de105742b54 100644 --- a/pkg/providers/amifamily/bootstrap/bottlerocket.go +++ b/pkg/providers/amifamily/bootstrap/bottlerocket.go @@ -42,6 +42,7 @@ func (b Bottlerocket) Script() (string, error) { s.Settings.Kubernetes.ClusterName = &b.ClusterName s.Settings.Kubernetes.APIServer = &b.ClusterEndpoint s.Settings.Kubernetes.ClusterCertificate = b.CABundle + s.Settings.Kubernetes.ClusterCIDR = b.ClusterCIDR if err := mergo.MergeWithOverwrite(&s.Settings.Kubernetes.NodeLabels, b.Labels); err != nil { return "", err } diff --git a/pkg/providers/amifamily/bootstrap/bottlerocketsettings.go b/pkg/providers/amifamily/bootstrap/bottlerocketsettings.go index 3e3e9bdf8ffd..ed279e9ce539 100644 --- a/pkg/providers/amifamily/bootstrap/bottlerocketsettings.go +++ b/pkg/providers/amifamily/bootstrap/bottlerocketsettings.go @@ -48,6 +48,7 @@ type BottlerocketKubernetes struct { CloudProvider *string `toml:"cloud-provider"` ClusterCertificate *string `toml:"cluster-certificate"` ClusterName *string `toml:"cluster-name"` + ClusterCIDR *string `toml:"cluster-cidr,omitempty"` ClusterDNSIP *string `toml:"cluster-dns-ip,omitempty"` CredentialProviders map[string]BottlerocketCredentialProvider `toml:"credential-providers,omitempty"` NodeLabels map[string]string `toml:"node-labels,omitempty"` diff --git a/pkg/providers/amifamily/bottlerocket.go b/pkg/providers/amifamily/bottlerocket.go index b0498976b52b..fe62217716e0 100644 --- a/pkg/providers/amifamily/bottlerocket.go +++ b/pkg/providers/amifamily/bottlerocket.go @@ -80,6 +80,7 @@ func (b Bottlerocket) UserData(kubeletConfig *v1.KubeletConfiguration, taints [] Options: bootstrap.Options{ ClusterName: b.Options.ClusterName, ClusterEndpoint: b.Options.ClusterEndpoint, + ClusterCIDR: b.Options.ClusterCIDR, KubeletConfig: kubeletConfig, Taints: taints, Labels: labels, diff --git a/pkg/providers/launchtemplate/testdata/br_userdata_merged.golden b/pkg/providers/launchtemplate/testdata/br_userdata_merged.golden index a9a425e55aba..54af5875057a 100644 --- a/pkg/providers/launchtemplate/testdata/br_userdata_merged.golden +++ b/pkg/providers/launchtemplate/testdata/br_userdata_merged.golden @@ -4,6 +4,7 @@ api-server = 'https://test-cluster' cloud-provider = 'external' cluster-certificate = 'ca-bundle' cluster-name = 'test-cluster' +cluster-cidr = '10.100.0.0/16' cluster-dns-ip = '10.0.100.10' max-pods = 110 diff --git a/pkg/providers/launchtemplate/testdata/br_userdata_unmerged.golden b/pkg/providers/launchtemplate/testdata/br_userdata_unmerged.golden index b81fe613e8e0..745848ffd326 100644 --- a/pkg/providers/launchtemplate/testdata/br_userdata_unmerged.golden +++ b/pkg/providers/launchtemplate/testdata/br_userdata_unmerged.golden @@ -3,6 +3,7 @@ api-server = 'https://test-cluster' cluster-certificate = 'ca-bundle' cluster-name = 'test-cluster' +cluster-cidr = '10.100.0.0/16' cluster-dns-ip = '10.0.100.10' max-pods = 110