@@ -52,7 +52,6 @@ import (
52
52
"sigs.k8s.io/cluster-api/util/certs"
53
53
containerutil "sigs.k8s.io/cluster-api/util/container"
54
54
"sigs.k8s.io/cluster-api/util/patch"
55
- "sigs.k8s.io/cluster-api/util/version"
56
55
)
57
56
58
57
const (
@@ -68,18 +67,6 @@ const (
68
67
)
69
68
70
69
var (
71
- // Starting from v1.22.0 kubeadm dropped the usage of the ClusterStatus entry from the kubeadm-config ConfigMap
72
- // so we're not anymore required to remove API endpoints for control plane nodes after deletion.
73
- //
74
- // NOTE: The following assumes that kubeadm version equals to Kubernetes version.
75
- minKubernetesVersionWithoutClusterStatus = semver .MustParse ("1.22.0" )
76
-
77
- // Starting from v1.21.0 kubeadm defaults to systemdCGroup driver, as well as images built with ImageBuilder,
78
- // so it is necessary to mutate the kubelet-config-xx ConfigMap.
79
- //
80
- // NOTE: The following assumes that kubeadm version equals to Kubernetes version.
81
- minVerKubeletSystemdDriver = semver .MustParse ("1.21.0" )
82
-
83
70
// Starting from v1.24.0 kubeadm uses "kubelet-config" a ConfigMap name for KubeletConfiguration,
84
71
// Dropping the X-Y suffix.
85
72
//
@@ -124,15 +111,13 @@ type WorkloadCluster interface {
124
111
UpdateKubeProxyImageInfo (ctx context.Context , kcp * controlplanev1.KubeadmControlPlane , version semver.Version ) error
125
112
UpdateCoreDNS (ctx context.Context , kcp * controlplanev1.KubeadmControlPlane , version semver.Version ) error
126
113
RemoveEtcdMemberForMachine (ctx context.Context , machine * clusterv1.Machine ) error
127
- RemoveMachineFromKubeadmConfigMap (ctx context.Context , machine * clusterv1.Machine , version semver.Version ) error
128
- RemoveNodeFromKubeadmConfigMap (ctx context.Context , nodeName string , version semver.Version ) error
129
114
ForwardEtcdLeadership (ctx context.Context , machine * clusterv1.Machine , leaderCandidate * clusterv1.Machine ) error
130
115
AllowBootstrapTokensToGetNodes (ctx context.Context ) error
131
116
AllowClusterAdminPermissions (ctx context.Context , version semver.Version ) error
132
117
UpdateClusterConfiguration (ctx context.Context , version semver.Version , mutators ... func (* bootstrapv1.ClusterConfiguration )) error
133
118
134
119
// State recovery tasks.
135
- ReconcileEtcdMembers (ctx context.Context , nodeNames []string , version semver. Version ) ([]string , error )
120
+ ReconcileEtcdMembers (ctx context.Context , nodeNames []string ) ([]string , error )
136
121
}
137
122
138
123
// Workload defines operations on workload clusters.
@@ -277,33 +262,31 @@ func (w *Workload) UpdateKubeletConfigMap(ctx context.Context, version semver.Ve
277
262
// NOTE: It is considered safe to update the kubelet-config-1.21 ConfigMap
278
263
// because only new nodes using v1.21 images will pick up the change during
279
264
// kubeadm join.
280
- if version .GE (minVerKubeletSystemdDriver ) {
281
- data , ok := cm .Data [kubeletConfigKey ]
282
- if ! ok {
283
- return errors .Errorf ("unable to find %q key in %s" , kubeletConfigKey , cm .Name )
284
- }
285
- kubeletConfig , err := yamlToUnstructured ([]byte (data ))
286
- if err != nil {
287
- return errors .Wrapf (err , "unable to decode kubelet ConfigMap's %q content to Unstructured object" , kubeletConfigKey )
288
- }
289
- cgroupDriver , _ , err := unstructured .NestedString (kubeletConfig .UnstructuredContent (), cgroupDriverKey )
290
- if err != nil {
291
- return errors .Wrapf (err , "unable to extract %q from Kubelet ConfigMap's %q" , cgroupDriverKey , cm .Name )
292
- }
265
+ data , ok := cm .Data [kubeletConfigKey ]
266
+ if ! ok {
267
+ return errors .Errorf ("unable to find %q key in %s" , kubeletConfigKey , cm .Name )
268
+ }
269
+ kubeletConfig , err := yamlToUnstructured ([]byte (data ))
270
+ if err != nil {
271
+ return errors .Wrapf (err , "unable to decode kubelet ConfigMap's %q content to Unstructured object" , kubeletConfigKey )
272
+ }
273
+ cgroupDriver , _ , err := unstructured .NestedString (kubeletConfig .UnstructuredContent (), cgroupDriverKey )
274
+ if err != nil {
275
+ return errors .Wrapf (err , "unable to extract %q from Kubelet ConfigMap's %q" , cgroupDriverKey , cm .Name )
276
+ }
293
277
294
- // If the value is not already explicitly set by the user, change according to kubeadm/image builder new requirements.
295
- if cgroupDriver == "" {
296
- cgroupDriver = "systemd"
278
+ // If the value is not already explicitly set by the user, change according to kubeadm/image builder new requirements.
279
+ if cgroupDriver == "" {
280
+ cgroupDriver = "systemd"
297
281
298
- if err := unstructured .SetNestedField (kubeletConfig .UnstructuredContent (), cgroupDriver , cgroupDriverKey ); err != nil {
299
- return errors .Wrapf (err , "unable to update %q on Kubelet ConfigMap's %q" , cgroupDriverKey , cm .Name )
300
- }
301
- updated , err := yaml .Marshal (kubeletConfig )
302
- if err != nil {
303
- return errors .Wrapf (err , "unable to encode Kubelet ConfigMap's %q to YAML" , cm .Name )
304
- }
305
- cm .Data [kubeletConfigKey ] = string (updated )
282
+ if err := unstructured .SetNestedField (kubeletConfig .UnstructuredContent (), cgroupDriver , cgroupDriverKey ); err != nil {
283
+ return errors .Wrapf (err , "unable to update %q on Kubelet ConfigMap's %q" , cgroupDriverKey , cm .Name )
306
284
}
285
+ updated , err := yaml .Marshal (kubeletConfig )
286
+ if err != nil {
287
+ return errors .Wrapf (err , "unable to encode Kubelet ConfigMap's %q to YAML" , cm .Name )
288
+ }
289
+ cm .Data [kubeletConfigKey ] = string (updated )
307
290
}
308
291
309
292
// Update the name to the new name
@@ -338,27 +321,6 @@ func (w *Workload) UpdateSchedulerInKubeadmConfigMap(scheduler bootstrapv1.Contr
338
321
}
339
322
}
340
323
341
- // RemoveMachineFromKubeadmConfigMap removes the entry for the machine from the kubeadm configmap.
342
- func (w * Workload ) RemoveMachineFromKubeadmConfigMap (ctx context.Context , machine * clusterv1.Machine , version semver.Version ) error {
343
- if machine == nil || machine .Status .NodeRef == nil {
344
- // Nothing to do, no node for Machine
345
- return nil
346
- }
347
-
348
- return w .RemoveNodeFromKubeadmConfigMap (ctx , machine .Status .NodeRef .Name , version )
349
- }
350
-
351
- // RemoveNodeFromKubeadmConfigMap removes the entry for the node from the kubeadm configmap.
352
- func (w * Workload ) RemoveNodeFromKubeadmConfigMap (ctx context.Context , name string , v semver.Version ) error {
353
- if version .Compare (v , minKubernetesVersionWithoutClusterStatus , version .WithoutPreReleases ()) >= 0 {
354
- return nil
355
- }
356
-
357
- return w .updateClusterStatus (ctx , func (s * bootstrapv1.ClusterStatus ) {
358
- delete (s .APIEndpoints , name )
359
- }, v )
360
- }
361
-
362
324
// updateClusterStatus gets the ClusterStatus kubeadm-config ConfigMap, converts it to the
363
325
// Cluster API representation, and then applies a mutation func; if changes are detected, the
364
326
// data are converted back into the Kubeadm API version in use for the target Kubernetes version and the
0 commit comments