Skip to content

feat: support setting kubeadm ignorePreflightErrors #1097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,20 @@ spec:
default: m5.xlarge
type: string
type: object
nodeRegistration:
description: NodeRegistration holds fields that relate to registering the new control-plane node to the cluster.
properties:
ignorePreflightErrors:
description: |-
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
when the current node is registered.
items:
maxLength: 512
minLength: 1
type: string
maxItems: 50
type: array
type: object
taints:
description: Taints specifies the taints the Node API object should be registered with.
items:
Expand Down
15 changes: 15 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_awsworkernodeconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ spec:
description: The AWS instance type to use for the cluster Machines.
type: string
type: object
nodeRegistration:
description: NodeRegistration holds fields that relate to registering
the new control-plane node to the cluster.
properties:
ignorePreflightErrors:
description: |-
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
when the current node is registered.
items:
maxLength: 512
minLength: 1
type: string
maxItems: 50
type: array
type: object
taints:
description: Taints specifies the taints the Node API object should
be registered with.
Expand Down
14 changes: 14 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,20 @@ spec:
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,})?$
type: string
type: object
nodeRegistration:
description: NodeRegistration holds fields that relate to registering the new control-plane node to the cluster.
properties:
ignorePreflightErrors:
description: |-
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
when the current node is registered.
items:
maxLength: 512
minLength: 1
type: string
maxItems: 50
type: array
type: object
taints:
description: Taints specifies the taints the Node API object should be registered with.
items:
Expand Down
15 changes: 15 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_dockerworkernodeconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ spec:
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,})?$
type: string
type: object
nodeRegistration:
description: NodeRegistration holds fields that relate to registering
the new control-plane node to the cluster.
properties:
ignorePreflightErrors:
description: |-
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
when the current node is registered.
items:
maxLength: 512
minLength: 1
type: string
maxItems: 50
type: array
type: object
taints:
description: Taints specifies the taints the Node API object should
be registered with.
Expand Down
14 changes: 14 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,20 @@ spec:
required:
- daysBeforeExpiry
type: object
nodeRegistration:
description: NodeRegistration holds fields that relate to registering the new control-plane node to the cluster.
properties:
ignorePreflightErrors:
description: |-
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
when the current node is registered.
items:
maxLength: 512
minLength: 1
type: string
maxItems: 50
type: array
type: object
nutanix:
properties:
machineDetails:
Expand Down
14 changes: 14 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_nutanixworkernodeconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ spec:
spec:
description: NutanixWorkerNodeConfigSpec defines the desired state of NutanixNodeSpec.
properties:
nodeRegistration:
description: NodeRegistration holds fields that relate to registering the new control-plane node to the cluster.
properties:
ignorePreflightErrors:
description: |-
IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
when the current node is registered.
items:
maxLength: 512
minLength: 1
type: string
maxItems: 50
type: array
type: object
nutanix:
properties:
machineDetails:
Expand Down
16 changes: 16 additions & 0 deletions api/v1alpha1/nodeconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ type GenericNodeSpec struct {
// Taints specifies the taints the Node API object should be registered with.
// +kubebuilder:validation:Optional
Taints []Taint `json:"taints,omitempty"`

// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster.
// +kubebuilder:validation:Optional
NodeRegistration *NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
}

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

// NodeRegistrationOptions holds fields that relate to registering a new control-plane or node to the cluster,
// either via "kubeadm init" or "kubeadm join".
type NodeRegistrationOptions struct {
// IgnorePreflightErrors specifies a slice of pre-flight errors to be ignored by kubeadm
// when the current node is registered.
// +kubebuilder:validation:Optional
// +kubebuilder:validation:MaxItems=50
// +kubebuilder:validation:items:MinLength=1
// +kubebuilder:validation:items:MaxLength=512
IgnorePreflightErrors []string `json:"ignorePreflightErrors,omitempty"`
}

//nolint:gochecknoinits // Idiomatic to use init functions to register APIs with scheme.
func init() {
SchemeBuilder.Register(
Expand Down
25 changes: 25 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 86 additions & 0 deletions docs/content/customization/generic/node-registration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
+++
title = "Node registration configuration"
+++

Below is a list of node registration configuration options that can be set for `kubeadm init` and `kubeadm join`.

This customization will be available when the
[provider-specific cluster configuration patch]({{< ref "..">}}) is included in the `ClusterClass`.

## Example

### ignorePreflightErrors

#### Control plane

To configure `ignorePreflightErrors` for the control plane nodes, specify the following configuration:

```yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: <NAME>
spec:
topology:
variables:
- name: clusterConfig
value:
controlPlane:
nodeRegistration:
ignorePreflightErrors:
- SystemVerification
```

Applying this configuration will result in the following value being set:

- `KubeadmControlPlaneTemplate`:

- ```yaml
spec:
kubeadmConfigSpec:
initConfiguration:
nodeRegistration:
nodeRegistration:
ignorePreflightErrors:
- SystemVerification
joinConfiguration:
nodeRegistration:
ignorePreflightErrors:
- SystemVerification
```

#### Worker node

Taints for individual nodepools can be configured similarly:

```yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: <NAME>
spec:
topology:
workers:
machineDeployments:
- class: default-worker
name: md-0
variables:
overrides:
- name: workerConfig
value:
nodeRegistration:
ignorePreflightErrors:
- SystemVerification
```

Applying this configuration will result in the following value being set:

- `KubeadmConfigTemplate`:

- ```yaml
spec:
joinConfiguration:
nodeRegistration:
ignorePreflightErrors:
- SystemVerification
```
3 changes: 3 additions & 0 deletions pkg/handlers/generic/mutation/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/imageregistries/credentials"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/kubernetesimagerepository"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/mirrors"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/noderegistration"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/taints"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/users"
)
Expand Down Expand Up @@ -59,11 +60,13 @@ func MetaMutators(mgr manager.Manager) []mutation.MetaMutator {
func ControlPlaneMetaMutators() []mutation.MetaMutator {
return []mutation.MetaMutator{
taints.NewControlPlanePatch(),
noderegistration.NewControlPlanePatch(),
}
}

func WorkerMetaMutators() []mutation.MetaMutator {
return []mutation.MetaMutator{
taints.NewWorkerPatch(),
noderegistration.NewWorkerPatch(),
}
}
Loading
Loading