Skip to content

Commit fda72a5

Browse files
committed
feat: support kubeadm nodeRegistration options per nodepool and control plane
1 parent 473d124 commit fda72a5

16 files changed

+607
-0
lines changed

Diff for: api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,20 @@ spec:
377377
default: m5.xlarge
378378
type: string
379379
type: object
380+
nodeRegistration:
381+
description: NodeRegistration holds fields that relate to registering the new control-plane node to the cluster.
382+
properties:
383+
ignorePreflightErrors:
384+
description: |-
385+
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
386+
when the current node is registered.
387+
items:
388+
maxLength: 512
389+
minLength: 1
390+
type: string
391+
maxItems: 50
392+
type: array
393+
type: object
380394
taints:
381395
description: Taints specifies the taints the Node API object should be registered with.
382396
items:

Diff for: api/v1alpha1/crds/caren.nutanix.com_awsworkernodeconfigs.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ spec:
9090
description: The AWS instance type to use for the cluster Machines.
9191
type: string
9292
type: object
93+
nodeRegistration:
94+
description: NodeRegistration holds fields that relate to registering
95+
the new control-plane node to the cluster.
96+
properties:
97+
ignorePreflightErrors:
98+
description: |-
99+
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
100+
when the current node is registered.
101+
items:
102+
maxLength: 512
103+
minLength: 1
104+
type: string
105+
maxItems: 50
106+
type: array
107+
type: object
93108
taints:
94109
description: Taints specifies the taints the Node API object should
95110
be registered with.

Diff for: api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,20 @@ spec:
306306
pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*(:[\w][\w.-]{0,127})?(@[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][0-9A-Fa-f]{32,})?$
307307
type: string
308308
type: object
309+
nodeRegistration:
310+
description: NodeRegistration holds fields that relate to registering the new control-plane node to the cluster.
311+
properties:
312+
ignorePreflightErrors:
313+
description: |-
314+
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
315+
when the current node is registered.
316+
items:
317+
maxLength: 512
318+
minLength: 1
319+
type: string
320+
maxItems: 50
321+
type: array
322+
type: object
309323
taints:
310324
description: Taints specifies the taints the Node API object should be registered with.
311325
items:

Diff for: api/v1alpha1/crds/caren.nutanix.com_dockerworkernodeconfigs.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ spec:
6565
pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*(:[\w][\w.-]{0,127})?(@[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][0-9A-Fa-f]{32,})?$
6666
type: string
6767
type: object
68+
nodeRegistration:
69+
description: NodeRegistration holds fields that relate to registering
70+
the new control-plane node to the cluster.
71+
properties:
72+
ignorePreflightErrors:
73+
description: |-
74+
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
75+
when the current node is registered.
76+
items:
77+
maxLength: 512
78+
minLength: 1
79+
type: string
80+
maxItems: 50
81+
type: array
82+
type: object
6883
taints:
6984
description: Taints specifies the taints the Node API object should
7085
be registered with.

Diff for: api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,20 @@ spec:
299299
required:
300300
- daysBeforeExpiry
301301
type: object
302+
nodeRegistration:
303+
description: NodeRegistration holds fields that relate to registering the new control-plane node to the cluster.
304+
properties:
305+
ignorePreflightErrors:
306+
description: |-
307+
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
308+
when the current node is registered.
309+
items:
310+
maxLength: 512
311+
minLength: 1
312+
type: string
313+
maxItems: 50
314+
type: array
315+
type: object
302316
nutanix:
303317
properties:
304318
machineDetails:

Diff for: api/v1alpha1/crds/caren.nutanix.com_nutanixworkernodeconfigs.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ spec:
4141
spec:
4242
description: NutanixWorkerNodeConfigSpec defines the desired state of NutanixNodeSpec.
4343
properties:
44+
nodeRegistration:
45+
description: NodeRegistration holds fields that relate to registering the new control-plane node to the cluster.
46+
properties:
47+
ignorePreflightErrors:
48+
description: |-
49+
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
50+
when the current node is registered.
51+
items:
52+
maxLength: 512
53+
minLength: 1
54+
type: string
55+
maxItems: 50
56+
type: array
57+
type: object
4458
nutanix:
4559
properties:
4660
machineDetails:

Diff for: api/v1alpha1/nodeconfig_types.go

+16
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ type GenericNodeSpec struct {
106106
// Taints specifies the taints the Node API object should be registered with.
107107
// +kubebuilder:validation:Optional
108108
Taints []Taint `json:"taints,omitempty"`
109+
110+
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster.
111+
// +kubebuilder:validation:Optional
112+
NodeRegistration *NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
109113
}
110114

111115
// The node this Taint is attached to has the "effect" on
@@ -146,6 +150,18 @@ const (
146150
TaintEffectNoExecute TaintEffect = "NoExecute"
147151
)
148152

153+
// NodeRegistrationOptions holds fields that relate to registering a new control-plane or node to the cluster,
154+
// either via "kubeadm init" or "kubeadm join".
155+
type NodeRegistrationOptions struct {
156+
// IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
157+
// when the current node is registered.
158+
// +kubebuilder:validation:Optional
159+
// +kubebuilder:validation:MaxItems=50
160+
// +kubebuilder:validation:items:MinLength=1
161+
// +kubebuilder:validation:items:MaxLength=512
162+
IgnorePreflightErrors []string `json:"ignorePreflightErrors,omitempty"`
163+
}
164+
149165
//nolint:gochecknoinits // Idiomatic to use init functions to register APIs with scheme.
150166
func init() {
151167
SchemeBuilder.Register(

Diff for: api/v1alpha1/zz_generated.deepcopy.go

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
+++
2+
title = "Node registration configuration"
3+
+++
4+
5+
Below is a list of node registration configuration options that can be set for `kubeadm init` and `kubeadm join`.
6+
7+
This customization will be available when the
8+
[provider-specific cluster configuration patch]({{< ref "..">}}) is included in the `ClusterClass`.
9+
10+
## Example
11+
12+
### ignorePreflightErrors
13+
14+
#### Control plane
15+
16+
To configure `ignorePreflightErrors` for the control plane nodes, specify the following configuration:
17+
18+
```yaml
19+
apiVersion: cluster.x-k8s.io/v1beta1
20+
kind: Cluster
21+
metadata:
22+
name: <NAME>
23+
spec:
24+
topology:
25+
variables:
26+
- name: clusterConfig
27+
value:
28+
controlPlane:
29+
nodeRegistration:
30+
ignorePreflightErrors:
31+
- SystemVerification
32+
```
33+
34+
Applying this configuration will result in the following value being set:
35+
36+
- `KubeadmControlPlaneTemplate`:
37+
38+
- ```yaml
39+
spec:
40+
kubeadmConfigSpec:
41+
initConfiguration:
42+
nodeRegistration:
43+
nodeRegistration:
44+
ignorePreflightErrors:
45+
- SystemVerification
46+
joinConfiguration:
47+
nodeRegistration:
48+
ignorePreflightErrors:
49+
- SystemVerification
50+
```
51+
52+
#### Worker node
53+
54+
Taints for individual nodepools can be configured similarly:
55+
56+
```yaml
57+
apiVersion: cluster.x-k8s.io/v1beta1
58+
kind: Cluster
59+
metadata:
60+
name: <NAME>
61+
spec:
62+
topology:
63+
workers:
64+
machineDeployments:
65+
- class: default-worker
66+
name: md-0
67+
variables:
68+
overrides:
69+
- name: workerConfig
70+
value:
71+
nodeRegistration:
72+
ignorePreflightErrors:
73+
- SystemVerification
74+
```
75+
76+
Applying this configuration will result in the following value being set:
77+
78+
- `KubeadmConfigTemplate`:
79+
80+
- ```yaml
81+
spec:
82+
joinConfiguration:
83+
nodeRegistration:
84+
ignorePreflightErrors:
85+
- SystemVerification
86+
```

Diff for: pkg/handlers/generic/mutation/handlers.go

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/imageregistries/credentials"
2222
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/kubernetesimagerepository"
2323
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/mirrors"
24+
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/noderegistration"
2425
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/taints"
2526
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/users"
2627
)
@@ -59,11 +60,13 @@ func MetaMutators(mgr manager.Manager) []mutation.MetaMutator {
5960
func ControlPlaneMetaMutators() []mutation.MetaMutator {
6061
return []mutation.MetaMutator{
6162
taints.NewControlPlanePatch(),
63+
noderegistration.NewControlPlanePatch(),
6264
}
6365
}
6466

6567
func WorkerMetaMutators() []mutation.MetaMutator {
6668
return []mutation.MetaMutator{
6769
taints.NewWorkerPatch(),
70+
noderegistration.NewWorkerPatch(),
6871
}
6972
}

0 commit comments

Comments
 (0)