Skip to content

Commit e9d6d43

Browse files
Merge pull request #2651 from ngopalak-redhat/ngopalak/autonode_doc
NO-ISSUE: Fixes KubeletConfig API doc, adds tests and kubebuilder validation
2 parents 80fcf45 + ceacb94 commit e9d6d43

6 files changed

Lines changed: 190 additions & 41 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "KubeletConfig"
3+
crdName: kubeletconfigs.machineconfiguration.openshift.io
4+
tests:
5+
onCreate:
6+
# LogLevel Boundary Tests
7+
- name: Should be able to set logLevel to 0 (minimum)
8+
initial: |
9+
apiVersion: machineconfiguration.openshift.io/v1
10+
kind: KubeletConfig
11+
spec:
12+
logLevel: 0
13+
expected: |
14+
apiVersion: machineconfiguration.openshift.io/v1
15+
kind: KubeletConfig
16+
spec:
17+
logLevel: 0
18+
- name: Should be able to set logLevel to 10 (maximum)
19+
initial: |
20+
apiVersion: machineconfiguration.openshift.io/v1
21+
kind: KubeletConfig
22+
spec:
23+
logLevel: 10
24+
expected: |
25+
apiVersion: machineconfiguration.openshift.io/v1
26+
kind: KubeletConfig
27+
spec:
28+
logLevel: 10
29+
- name: Should reject logLevel less than 0
30+
initial: |
31+
apiVersion: machineconfiguration.openshift.io/v1
32+
kind: KubeletConfig
33+
spec:
34+
logLevel: -1
35+
expectedError: "Invalid value"
36+
- name: Should reject logLevel greater than 10
37+
initial: |
38+
apiVersion: machineconfiguration.openshift.io/v1
39+
kind: KubeletConfig
40+
spec:
41+
logLevel: 11
42+
expectedError: "Invalid value"
43+
44+
onUpdate:
45+
# Ratcheting tests - ensure existing objects with previously valid values can be updated
46+
- name: Should allow updating other fields with a previously valid logLevel outside current range
47+
initialCRDPatches:
48+
- op: remove
49+
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/logLevel/maximum
50+
- op: remove
51+
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/logLevel/minimum
52+
initial: |
53+
apiVersion: machineconfiguration.openshift.io/v1
54+
kind: KubeletConfig
55+
spec:
56+
logLevel: 15
57+
updated: |
58+
apiVersion: machineconfiguration.openshift.io/v1
59+
kind: KubeletConfig
60+
spec:
61+
logLevel: 15
62+
autoSizingReserved: true
63+
expected: |
64+
apiVersion: machineconfiguration.openshift.io/v1
65+
kind: KubeletConfig
66+
spec:
67+
logLevel: 15
68+
autoSizingReserved: true
69+
- name: Should allow migrating from invalid logLevel to valid value
70+
initialCRDPatches:
71+
- op: remove
72+
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/logLevel/maximum
73+
- op: remove
74+
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/logLevel/minimum
75+
initial: |
76+
apiVersion: machineconfiguration.openshift.io/v1
77+
kind: KubeletConfig
78+
spec:
79+
logLevel: 15
80+
updated: |
81+
apiVersion: machineconfiguration.openshift.io/v1
82+
kind: KubeletConfig
83+
spec:
84+
logLevel: 5
85+
expected: |
86+
apiVersion: machineconfiguration.openshift.io/v1
87+
kind: KubeletConfig
88+
spec:
89+
logLevel: 5

machineconfiguration/v1/types.go

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -732,27 +732,40 @@ type KubeletConfig struct {
732732
Status KubeletConfigStatus `json:"status"`
733733
}
734734

735-
// KubeletConfigSpec defines the desired state of KubeletConfig
735+
// KubeletConfigSpec configures the kubelet running on cluster nodes.
736736
type KubeletConfigSpec struct {
737+
// autoSizingReserved controls whether system-reserved CPU and memory are automatically
738+
// calculated based on each node's installed capacity. When set to true, this prevents node failure
739+
// from resource starvation of system components (kubelet, CRI-O) without manual configuration.
740+
// When omitted, this means the user has no opinion and the platform is left to choose a reasonable default,
741+
// which is subject to change over time. The current default is true for worker nodes and false for control plane nodes.
742+
// When set to false, automatic resource reservation is disabled and manual settings must be configured.
737743
// +optional
738744
AutoSizingReserved *bool `json:"autoSizingReserved,omitempty"`
745+
// logLevel sets the kubelet log verbosity, controlling the amount of detail in kubelet logs.
746+
// Valid values range from 0 (minimal logging) to 10 (maximum verbosity with trace-level detail).
747+
// Higher log levels may impact node performance. When omitted, the platform chooses a reasonable default,
748+
// which is subject to change over time. The current default is 2 (standard informational logging).
749+
// +kubebuilder:validation:Minimum=0
750+
// +kubebuilder:validation:Maximum=10
739751
// +optional
740752
LogLevel *int32 `json:"logLevel,omitempty"`
741753

742-
// machineConfigPoolSelector selects which pools the KubeletConfig shoud apply to.
743-
// A nil selector will result in no pools being selected.
754+
// machineConfigPoolSelector selects which pools the KubeletConfig should apply to.
755+
// When omitted or set to an empty selector {}, no pools are selected, which is equivalent
756+
// to not matching any MachineConfigPool.
744757
// +optional
745758
MachineConfigPoolSelector *metav1.LabelSelector `json:"machineConfigPoolSelector,omitempty"`
746-
// kubeletConfig fields are defined in kubernetes upstream. Please refer to the types defined in the version/commit used by
747-
// OpenShift of the upstream kubernetes. It's important to note that, since the fields of the kubelet configuration are directly fetched from
748-
// upstream the validation of those values is handled directly by the kubelet. Please refer to the upstream version of the relevant kubernetes
749-
// for the valid values of these fields. Invalid values of the kubelet configuration fields may render cluster nodes unusable.
759+
// kubeletConfig contains upstream Kubernetes kubelet configuration fields.
760+
// Values are validated by the kubelet itself. Invalid values may render nodes unusable.
761+
// Refer to OpenShift documentation for the Kubernetes version corresponding to your
762+
// OpenShift release to find valid kubelet configuration options.
750763
// +optional
751764
KubeletConfig *runtime.RawExtension `json:"kubeletConfig,omitempty"`
752765

753-
// If unset, the default is based on the apiservers.config.openshift.io/cluster resource.
754-
// Note that only Old and Intermediate profiles are currently supported, and
755-
// the maximum available minTLSVersion is VersionTLS12.
766+
// tlsSecurityProfile configures TLS settings for the kubelet.
767+
// When omitted, the TLS configuration defaults to the value from apiservers.config.openshift.io/cluster.
768+
// When specified, the type field can be set to either "Old", "Intermediate", "Modern", "Custom" or omitted for backward compatibility.
756769
// +optional
757770
TLSSecurityProfile *configv1.TLSSecurityProfile `json:"tlsSecurityProfile,omitempty"`
758771
}

machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_kubeletconfigs.crd.yaml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,37 @@ spec:
4747
description: spec contains the desired kubelet configuration.
4848
properties:
4949
autoSizingReserved:
50+
description: |-
51+
autoSizingReserved controls whether system-reserved CPU and memory are automatically
52+
calculated based on each node's installed capacity. When set to true, this prevents node failure
53+
from resource starvation of system components (kubelet, CRI-O) without manual configuration.
54+
When omitted, this means the user has no opinion and the platform is left to choose a reasonable default,
55+
which is subject to change over time. The current default is true for worker nodes and false for control plane nodes.
56+
When set to false, automatic resource reservation is disabled and manual settings must be configured.
5057
type: boolean
5158
kubeletConfig:
5259
description: |-
53-
kubeletConfig fields are defined in kubernetes upstream. Please refer to the types defined in the version/commit used by
54-
OpenShift of the upstream kubernetes. It's important to note that, since the fields of the kubelet configuration are directly fetched from
55-
upstream the validation of those values is handled directly by the kubelet. Please refer to the upstream version of the relevant kubernetes
56-
for the valid values of these fields. Invalid values of the kubelet configuration fields may render cluster nodes unusable.
60+
kubeletConfig contains upstream Kubernetes kubelet configuration fields.
61+
Values are validated by the kubelet itself. Invalid values may render nodes unusable.
62+
Refer to OpenShift documentation for the Kubernetes version corresponding to your
63+
OpenShift release to find valid kubelet configuration options.
5764
type: object
5865
x-kubernetes-preserve-unknown-fields: true
5966
logLevel:
67+
description: |-
68+
logLevel sets the kubelet log verbosity, controlling the amount of detail in kubelet logs.
69+
Valid values range from 0 (minimal logging) to 10 (maximum verbosity with trace-level detail).
70+
Higher log levels may impact node performance. When omitted, the platform chooses a reasonable default,
71+
which is subject to change over time. The current default is 2 (standard informational logging).
6072
format: int32
73+
maximum: 10
74+
minimum: 0
6175
type: integer
6276
machineConfigPoolSelector:
6377
description: |-
64-
machineConfigPoolSelector selects which pools the KubeletConfig shoud apply to.
65-
A nil selector will result in no pools being selected.
78+
machineConfigPoolSelector selects which pools the KubeletConfig should apply to.
79+
When omitted or set to an empty selector {}, no pools are selected, which is equivalent
80+
to not matching any MachineConfigPool.
6681
properties:
6782
matchExpressions:
6883
description: matchExpressions is a list of label selector requirements.
@@ -109,9 +124,9 @@ spec:
109124
x-kubernetes-map-type: atomic
110125
tlsSecurityProfile:
111126
description: |-
112-
If unset, the default is based on the apiservers.config.openshift.io/cluster resource.
113-
Note that only Old and Intermediate profiles are currently supported, and
114-
the maximum available minTLSVersion is VersionTLS12.
127+
tlsSecurityProfile configures TLS settings for the kubelet.
128+
When omitted, the TLS configuration defaults to the value from apiservers.config.openshift.io/cluster.
129+
When specified, the type field can be set to either "Old", "Intermediate", "Modern", "Custom" or omitted for backward compatibility.
115130
properties:
116131
custom:
117132
description: |-

machineconfiguration/v1/zz_generated.featuregated-crd-manifests/kubeletconfigs.machineconfiguration.openshift.io/AAA_ungated.yaml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,37 @@ spec:
4848
description: spec contains the desired kubelet configuration.
4949
properties:
5050
autoSizingReserved:
51+
description: |-
52+
autoSizingReserved controls whether system-reserved CPU and memory are automatically
53+
calculated based on each node's installed capacity. When set to true, this prevents node failure
54+
from resource starvation of system components (kubelet, CRI-O) without manual configuration.
55+
When omitted, this means the user has no opinion and the platform is left to choose a reasonable default,
56+
which is subject to change over time. The current default is true for worker nodes and false for control plane nodes.
57+
When set to false, automatic resource reservation is disabled and manual settings must be configured.
5158
type: boolean
5259
kubeletConfig:
5360
description: |-
54-
kubeletConfig fields are defined in kubernetes upstream. Please refer to the types defined in the version/commit used by
55-
OpenShift of the upstream kubernetes. It's important to note that, since the fields of the kubelet configuration are directly fetched from
56-
upstream the validation of those values is handled directly by the kubelet. Please refer to the upstream version of the relevant kubernetes
57-
for the valid values of these fields. Invalid values of the kubelet configuration fields may render cluster nodes unusable.
61+
kubeletConfig contains upstream Kubernetes kubelet configuration fields.
62+
Values are validated by the kubelet itself. Invalid values may render nodes unusable.
63+
Refer to OpenShift documentation for the Kubernetes version corresponding to your
64+
OpenShift release to find valid kubelet configuration options.
5865
type: object
5966
x-kubernetes-preserve-unknown-fields: true
6067
logLevel:
68+
description: |-
69+
logLevel sets the kubelet log verbosity, controlling the amount of detail in kubelet logs.
70+
Valid values range from 0 (minimal logging) to 10 (maximum verbosity with trace-level detail).
71+
Higher log levels may impact node performance. When omitted, the platform chooses a reasonable default,
72+
which is subject to change over time. The current default is 2 (standard informational logging).
6173
format: int32
74+
maximum: 10
75+
minimum: 0
6276
type: integer
6377
machineConfigPoolSelector:
6478
description: |-
65-
machineConfigPoolSelector selects which pools the KubeletConfig shoud apply to.
66-
A nil selector will result in no pools being selected.
79+
machineConfigPoolSelector selects which pools the KubeletConfig should apply to.
80+
When omitted or set to an empty selector {}, no pools are selected, which is equivalent
81+
to not matching any MachineConfigPool.
6782
properties:
6883
matchExpressions:
6984
description: matchExpressions is a list of label selector requirements.
@@ -110,9 +125,9 @@ spec:
110125
x-kubernetes-map-type: atomic
111126
tlsSecurityProfile:
112127
description: |-
113-
If unset, the default is based on the apiservers.config.openshift.io/cluster resource.
114-
Note that only Old and Intermediate profiles are currently supported, and
115-
the maximum available minTLSVersion is VersionTLS12.
128+
tlsSecurityProfile configures TLS settings for the kubelet.
129+
When omitted, the TLS configuration defaults to the value from apiservers.config.openshift.io/cluster.
130+
When specified, the type field can be set to either "Old", "Intermediate", "Modern", "Custom" or omitted for backward compatibility.
116131
properties:
117132
custom:
118133
description: |-

machineconfiguration/v1/zz_generated.swagger_doc_generated.go

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

0 commit comments

Comments
 (0)