Skip to content

Commit 686d66b

Browse files
authored
⚠️ Remove redundant fields from CABPK / KCP ClusterConfiguration (#12319)
* Remove redundant fields from ClusterConfiguration * Fix doc finding * Optimize conversion
1 parent 117dcf0 commit 686d66b

40 files changed

+652
-960
lines changed

api/bootstrap/kubeadm/v1beta1/conversion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ func Convert_v1beta1_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in *KubeadmC
240240
return autoConvert_v1beta1_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in, out, s)
241241
}
242242

243+
func Convert_v1beta1_ClusterConfiguration_To_v1beta2_ClusterConfiguration(in *ClusterConfiguration, out *bootstrapv1.ClusterConfiguration, s apimachineryconversion.Scope) error {
244+
return autoConvert_v1beta1_ClusterConfiguration_To_v1beta2_ClusterConfiguration(in, out, s)
245+
}
246+
243247
func Convert_v1beta1_ControlPlaneComponent_To_v1beta2_ControlPlaneComponent(in *ControlPlaneComponent, out *bootstrapv1.ControlPlaneComponent, s apimachineryconversion.Scope) error {
244248
out.ExtraArgs = bootstrapv1.ConvertToArgs(in.ExtraArgs)
245249
return autoConvert_v1beta1_ControlPlaneComponent_To_v1beta2_ControlPlaneComponent(in, out, s)

api/bootstrap/kubeadm/v1beta1/conversion_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func KubeadmConfigFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
6060
spokeDiscovery,
6161
spokeKubeadmConfigSpec,
6262
spokeKubeadmConfigStatus,
63+
spokeClusterConfiguration,
6364
hubBootstrapTokenString,
6465
spokeBootstrapTokenString,
6566
hubKubeadmConfigSpec,
@@ -71,6 +72,7 @@ func KubeadmConfigTemplateFuzzFuncs(_ runtimeserializer.CodecFactory) []interfac
7172
spokeAPIServer,
7273
spokeDiscovery,
7374
spokeKubeadmConfigSpec,
75+
spokeClusterConfiguration,
7476
spokeBootstrapTokenString,
7577
hubBootstrapTokenString,
7678
hubKubeadmConfigSpec,
@@ -131,6 +133,18 @@ func spokeKubeadmConfigSpec(in *KubeadmConfigSpec, c randfill.Continue) {
131133
in.UseExperimentalRetryJoin = false
132134
}
133135

136+
func spokeClusterConfiguration(in *ClusterConfiguration, c randfill.Continue) {
137+
c.FillNoCustom(in)
138+
139+
// Drop the following fields as they have been removed in v1beta2, so we don't have to preserve them.
140+
in.Networking.ServiceSubnet = ""
141+
in.Networking.PodSubnet = ""
142+
in.Networking.DNSDomain = ""
143+
in.KubernetesVersion = ""
144+
in.ControlPlaneEndpoint = ""
145+
in.ClusterName = ""
146+
}
147+
134148
func spokeAPIServer(in *APIServer, c randfill.Continue) {
135149
c.FillNoCustom(in)
136150

api/bootstrap/kubeadm/v1beta1/zz_generated.conversion.go

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

api/bootstrap/kubeadm/v1beta2/kubeadm_types.go

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -130,35 +130,6 @@ type ClusterConfiguration struct {
130130
// +optional
131131
Etcd Etcd `json:"etcd,omitempty"`
132132

133-
// networking holds configuration for the networking topology of the cluster.
134-
// NB: This value defaults to the Cluster object spec.clusterNetwork.
135-
// +optional
136-
Networking Networking `json:"networking,omitempty"`
137-
138-
// kubernetesVersion is the target version of the control plane.
139-
// NB: This value defaults to the Machine object spec.version
140-
// +optional
141-
// +kubebuilder:validation:MinLength=1
142-
// +kubebuilder:validation:MaxLength=256
143-
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
144-
145-
// controlPlaneEndpoint sets a stable IP address or DNS name for the control plane; it
146-
// can be a valid IP address or a RFC-1123 DNS subdomain, both with optional TCP port.
147-
// In case the ControlPlaneEndpoint is not specified, the AdvertiseAddress + BindPort
148-
// are used; in case the ControlPlaneEndpoint is specified but without a TCP port,
149-
// the BindPort is used.
150-
// Possible usages are:
151-
// e.g. In a cluster with more than one control plane instances, this field should be
152-
// assigned the address of the external load balancer in front of the
153-
// control plane instances.
154-
// e.g. in environments with enforced node recycling, the ControlPlaneEndpoint
155-
// could be used for assigning a stable DNS to the control plane.
156-
// NB: This value defaults to the first value in the Cluster object status.apiEndpoints array.
157-
// +optional
158-
// +kubebuilder:validation:MinLength=1
159-
// +kubebuilder:validation:MaxLength=512
160-
ControlPlaneEndpoint string `json:"controlPlaneEndpoint,omitempty"`
161-
162133
// apiServer contains extra settings for the API server control plane component
163134
// +optional
164135
APIServer APIServer `json:"apiServer,omitempty"`
@@ -201,12 +172,6 @@ type ClusterConfiguration struct {
201172
// featureGates enabled by the user.
202173
// +optional
203174
FeatureGates map[string]bool `json:"featureGates,omitempty"`
204-
205-
// clusterName is the cluster name
206-
// +optional
207-
// +kubebuilder:validation:MinLength=1
208-
// +kubebuilder:validation:MaxLength=63
209-
ClusterName string `json:"clusterName,omitempty"`
210175
}
211176

212177
// ControlPlaneComponent holds settings common to control plane component of the cluster.
@@ -416,29 +381,6 @@ func (n *NodeRegistrationOptions) MarshalJSON() ([]byte, error) {
416381
})
417382
}
418383

419-
// Networking contains elements describing cluster's networking configuration.
420-
type Networking struct {
421-
// serviceSubnet is the subnet used by k8s services.
422-
// Defaults to a comma-delimited string of the Cluster object's spec.clusterNetwork.pods.cidrBlocks, or
423-
// to "10.96.0.0/12" if that's unset.
424-
// +optional
425-
// +kubebuilder:validation:MinLength=1
426-
// +kubebuilder:validation:MaxLength=1024
427-
ServiceSubnet string `json:"serviceSubnet,omitempty"`
428-
// podSubnet is the subnet used by pods.
429-
// If unset, the API server will not allocate CIDR ranges for every node.
430-
// Defaults to a comma-delimited string of the Cluster object's spec.clusterNetwork.services.cidrBlocks if that is set
431-
// +optional
432-
// +kubebuilder:validation:MinLength=1
433-
// +kubebuilder:validation:MaxLength=1024
434-
PodSubnet string `json:"podSubnet,omitempty"`
435-
// dnsDomain is the dns domain used by k8s services. Defaults to "cluster.local".
436-
// +optional
437-
// +kubebuilder:validation:MinLength=1
438-
// +kubebuilder:validation:MaxLength=253
439-
DNSDomain string `json:"dnsDomain,omitempty"`
440-
}
441-
442384
// BootstrapToken describes one bootstrap token, stored as a Secret in the cluster.
443385
type BootstrapToken struct {
444386
// token is used for establishing bidirectional trust between nodes and control-planes.

api/bootstrap/kubeadm/v1beta2/zz_generated.deepcopy.go

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

api/controlplane/kubeadm/v1beta1/conversion_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func KubeadmControlPlaneFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{
6060
hubKubeadmControlPlaneStatus,
6161
spokeKubeadmControlPlaneStatus,
6262
spokeKubeadmConfigSpec,
63+
spokeClusterConfiguration,
6364
hubBootstrapTokenString,
6465
spokeBootstrapTokenString,
6566
spokeAPIServer,
@@ -71,6 +72,7 @@ func KubeadmControlPlaneFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{
7172
func KubeadmControlPlaneTemplateFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
7273
return []interface{}{
7374
spokeKubeadmConfigSpec,
75+
spokeClusterConfiguration,
7476
hubBootstrapTokenString,
7577
spokeBootstrapTokenString,
7678
spokeAPIServer,
@@ -167,3 +169,15 @@ func spokeKubeadmConfigSpec(in *bootstrapv1beta1.KubeadmConfigSpec, c randfill.C
167169
// Drop UseExperimentalRetryJoin as we intentionally don't preserve it.
168170
in.UseExperimentalRetryJoin = false
169171
}
172+
173+
func spokeClusterConfiguration(in *bootstrapv1beta1.ClusterConfiguration, c randfill.Continue) {
174+
c.FillNoCustom(in)
175+
176+
// Drop the following fields as they have been removed in v1beta2, so we don't have to preserve them.
177+
in.Networking.ServiceSubnet = ""
178+
in.Networking.PodSubnet = ""
179+
in.Networking.DNSDomain = ""
180+
in.KubernetesVersion = ""
181+
in.ControlPlaneEndpoint = ""
182+
in.ClusterName = ""
183+
}

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml

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

0 commit comments

Comments
 (0)