Skip to content

Commit 8e0b9d6

Browse files
Fixes KubeletConfig API doc and adds tests
1 parent 6ab113c commit 8e0b9d6

6 files changed

Lines changed: 349 additions & 41 deletions

File tree

Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
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+
# AutoSizingReserved tests
7+
- name: Should be able to set autoSizingReserved to true
8+
initial: |
9+
apiVersion: machineconfiguration.openshift.io/v1
10+
kind: KubeletConfig
11+
spec:
12+
autoSizingReserved: true
13+
expected: |
14+
apiVersion: machineconfiguration.openshift.io/v1
15+
kind: KubeletConfig
16+
spec:
17+
autoSizingReserved: true
18+
- name: Should be able to set autoSizingReserved to false
19+
initial: |
20+
apiVersion: machineconfiguration.openshift.io/v1
21+
kind: KubeletConfig
22+
spec:
23+
autoSizingReserved: false
24+
expected: |
25+
apiVersion: machineconfiguration.openshift.io/v1
26+
kind: KubeletConfig
27+
spec:
28+
autoSizingReserved: false
29+
- name: Should be able to omit autoSizingReserved
30+
initial: |
31+
apiVersion: machineconfiguration.openshift.io/v1
32+
kind: KubeletConfig
33+
spec: {}
34+
expected: |
35+
apiVersion: machineconfiguration.openshift.io/v1
36+
kind: KubeletConfig
37+
spec: {}
38+
39+
# LogLevel tests
40+
- name: Should be able to set logLevel to 2
41+
initial: |
42+
apiVersion: machineconfiguration.openshift.io/v1
43+
kind: KubeletConfig
44+
spec:
45+
logLevel: 2
46+
expected: |
47+
apiVersion: machineconfiguration.openshift.io/v1
48+
kind: KubeletConfig
49+
spec:
50+
logLevel: 2
51+
- name: Should be able to set logLevel to 4
52+
initial: |
53+
apiVersion: machineconfiguration.openshift.io/v1
54+
kind: KubeletConfig
55+
spec:
56+
logLevel: 4
57+
expected: |
58+
apiVersion: machineconfiguration.openshift.io/v1
59+
kind: KubeletConfig
60+
spec:
61+
logLevel: 4
62+
- name: Should be able to omit logLevel
63+
initial: |
64+
apiVersion: machineconfiguration.openshift.io/v1
65+
kind: KubeletConfig
66+
spec: {}
67+
expected: |
68+
apiVersion: machineconfiguration.openshift.io/v1
69+
kind: KubeletConfig
70+
spec: {}
71+
72+
# MachineConfigPoolSelector tests
73+
- name: Should be able to set machineConfigPoolSelector for worker pool
74+
initial: |
75+
apiVersion: machineconfiguration.openshift.io/v1
76+
kind: KubeletConfig
77+
spec:
78+
machineConfigPoolSelector:
79+
matchLabels:
80+
pools.operator.machineconfiguration.openshift.io/worker: ""
81+
expected: |
82+
apiVersion: machineconfiguration.openshift.io/v1
83+
kind: KubeletConfig
84+
spec:
85+
machineConfigPoolSelector:
86+
matchLabels:
87+
pools.operator.machineconfiguration.openshift.io/worker: ""
88+
- name: Should be able to set machineConfigPoolSelector for master pool
89+
initial: |
90+
apiVersion: machineconfiguration.openshift.io/v1
91+
kind: KubeletConfig
92+
spec:
93+
machineConfigPoolSelector:
94+
matchLabels:
95+
pools.operator.machineconfiguration.openshift.io/master: ""
96+
expected: |
97+
apiVersion: machineconfiguration.openshift.io/v1
98+
kind: KubeletConfig
99+
spec:
100+
machineConfigPoolSelector:
101+
matchLabels:
102+
pools.operator.machineconfiguration.openshift.io/master: ""
103+
- name: Should be able to omit machineConfigPoolSelector
104+
initial: |
105+
apiVersion: machineconfiguration.openshift.io/v1
106+
kind: KubeletConfig
107+
spec: {}
108+
expected: |
109+
apiVersion: machineconfiguration.openshift.io/v1
110+
kind: KubeletConfig
111+
spec: {}
112+
113+
# KubeletConfig tests
114+
- name: Should be able to set kubeletConfig with maxPods
115+
initial: |
116+
apiVersion: machineconfiguration.openshift.io/v1
117+
kind: KubeletConfig
118+
spec:
119+
kubeletConfig:
120+
maxPods: 250
121+
expected: |
122+
apiVersion: machineconfiguration.openshift.io/v1
123+
kind: KubeletConfig
124+
spec:
125+
kubeletConfig:
126+
maxPods: 250
127+
- name: Should be able to omit kubeletConfig
128+
initial: |
129+
apiVersion: machineconfiguration.openshift.io/v1
130+
kind: KubeletConfig
131+
spec: {}
132+
expected: |
133+
apiVersion: machineconfiguration.openshift.io/v1
134+
kind: KubeletConfig
135+
spec: {}
136+
137+
# Combined fields tests
138+
- name: Should be able to set multiple fields together
139+
initial: |
140+
apiVersion: machineconfiguration.openshift.io/v1
141+
kind: KubeletConfig
142+
spec:
143+
autoSizingReserved: true
144+
logLevel: 2
145+
machineConfigPoolSelector:
146+
matchLabels:
147+
pools.operator.machineconfiguration.openshift.io/worker: ""
148+
kubeletConfig:
149+
maxPods: 250
150+
expected: |
151+
apiVersion: machineconfiguration.openshift.io/v1
152+
kind: KubeletConfig
153+
spec:
154+
autoSizingReserved: true
155+
logLevel: 2
156+
machineConfigPoolSelector:
157+
matchLabels:
158+
pools.operator.machineconfiguration.openshift.io/worker: ""
159+
kubeletConfig:
160+
maxPods: 250
161+
162+
onUpdate:
163+
# AutoSizingReserved update tests
164+
- name: Should be able to update autoSizingReserved from true to false
165+
initial: |
166+
apiVersion: machineconfiguration.openshift.io/v1
167+
kind: KubeletConfig
168+
spec:
169+
autoSizingReserved: true
170+
updated: |
171+
apiVersion: machineconfiguration.openshift.io/v1
172+
kind: KubeletConfig
173+
spec:
174+
autoSizingReserved: false
175+
expected: |
176+
apiVersion: machineconfiguration.openshift.io/v1
177+
kind: KubeletConfig
178+
spec:
179+
autoSizingReserved: false
180+
- name: Should be able to update autoSizingReserved from false to true
181+
initial: |
182+
apiVersion: machineconfiguration.openshift.io/v1
183+
kind: KubeletConfig
184+
spec:
185+
autoSizingReserved: false
186+
updated: |
187+
apiVersion: machineconfiguration.openshift.io/v1
188+
kind: KubeletConfig
189+
spec:
190+
autoSizingReserved: true
191+
expected: |
192+
apiVersion: machineconfiguration.openshift.io/v1
193+
kind: KubeletConfig
194+
spec:
195+
autoSizingReserved: true
196+
197+
# LogLevel update tests
198+
- name: Should be able to update logLevel from 2 to 4
199+
initial: |
200+
apiVersion: machineconfiguration.openshift.io/v1
201+
kind: KubeletConfig
202+
spec:
203+
logLevel: 2
204+
updated: |
205+
apiVersion: machineconfiguration.openshift.io/v1
206+
kind: KubeletConfig
207+
spec:
208+
logLevel: 4
209+
expected: |
210+
apiVersion: machineconfiguration.openshift.io/v1
211+
kind: KubeletConfig
212+
spec:
213+
logLevel: 4
214+
- name: Should be able to remove logLevel
215+
initial: |
216+
apiVersion: machineconfiguration.openshift.io/v1
217+
kind: KubeletConfig
218+
spec:
219+
logLevel: 2
220+
updated: |
221+
apiVersion: machineconfiguration.openshift.io/v1
222+
kind: KubeletConfig
223+
spec: {}
224+
expected: |
225+
apiVersion: machineconfiguration.openshift.io/v1
226+
kind: KubeletConfig
227+
spec: {}
228+
229+
# MachineConfigPoolSelector update tests
230+
- name: Should be able to update machineConfigPoolSelector from worker to master
231+
initial: |
232+
apiVersion: machineconfiguration.openshift.io/v1
233+
kind: KubeletConfig
234+
spec:
235+
machineConfigPoolSelector:
236+
matchLabels:
237+
pools.operator.machineconfiguration.openshift.io/worker: ""
238+
updated: |
239+
apiVersion: machineconfiguration.openshift.io/v1
240+
kind: KubeletConfig
241+
spec:
242+
machineConfigPoolSelector:
243+
matchLabels:
244+
pools.operator.machineconfiguration.openshift.io/master: ""
245+
expected: |
246+
apiVersion: machineconfiguration.openshift.io/v1
247+
kind: KubeletConfig
248+
spec:
249+
machineConfigPoolSelector:
250+
matchLabels:
251+
pools.operator.machineconfiguration.openshift.io/master: ""
252+
253+
# Combined update tests
254+
- name: Should be able to update multiple fields together
255+
initial: |
256+
apiVersion: machineconfiguration.openshift.io/v1
257+
kind: KubeletConfig
258+
spec:
259+
autoSizingReserved: false
260+
logLevel: 2
261+
updated: |
262+
apiVersion: machineconfiguration.openshift.io/v1
263+
kind: KubeletConfig
264+
spec:
265+
autoSizingReserved: true
266+
logLevel: 4
267+
kubeletConfig:
268+
maxPods: 250
269+
expected: |
270+
apiVersion: machineconfiguration.openshift.io/v1
271+
kind: KubeletConfig
272+
spec:
273+
autoSizingReserved: true
274+
logLevel: 4
275+
kubeletConfig:
276+
maxPods: 250

machineconfiguration/v1/types.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -737,27 +737,33 @@ type KubeletConfig struct {
737737
Status KubeletConfigStatus `json:"status"`
738738
}
739739

740-
// KubeletConfigSpec defines the desired state of KubeletConfig
740+
// KubeletConfigSpec configures the kubelet running on cluster nodes.
741741
type KubeletConfigSpec struct {
742+
// autoSizingReserved controls whether system-reserved CPU and memory are automatically
743+
// calculated based on each node's installed capacity. When enabled, prevents node failure
744+
// from resource starvation of system components (kubelet, CRI-O) without manual configuration.
745+
// When unset or true, automatic sizing is enabled. Set to false to disable and use manual settings.
742746
// +optional
743747
AutoSizingReserved *bool `json:"autoSizingReserved,omitempty"`
748+
// logLevel sets the kubelet log verbosity. Higher values increase log detail.
749+
// Defaults to 2 if unset.
744750
// +optional
745751
LogLevel *int32 `json:"logLevel,omitempty"`
746752

747-
// machineConfigPoolSelector selects which pools the KubeletConfig shoud apply to.
748-
// A nil selector will result in no pools being selected.
753+
// machineConfigPoolSelector selects which pools the KubeletConfig should apply to.
754+
// A nil selector results in no pools being selected.
749755
// +optional
750756
MachineConfigPoolSelector *metav1.LabelSelector `json:"machineConfigPoolSelector,omitempty"`
751-
// kubeletConfig fields are defined in kubernetes upstream. Please refer to the types defined in the version/commit used by
752-
// OpenShift of the upstream kubernetes. It's important to note that, since the fields of the kubelet configuration are directly fetched from
753-
// upstream the validation of those values is handled directly by the kubelet. Please refer to the upstream version of the relevant kubernetes
754-
// for the valid values of these fields. Invalid values of the kubelet configuration fields may render cluster nodes unusable.
757+
// kubeletConfig contains upstream Kubernetes kubelet configuration fields.
758+
// Values are validated by the kubelet itself. Invalid values may render nodes unusable.
759+
// Refer to OpenShift documentation for the Kubernetes version corresponding to your
760+
// OpenShift release to find valid kubelet configuration options.
755761
// +optional
756762
KubeletConfig *runtime.RawExtension `json:"kubeletConfig,omitempty"`
757763

758-
// If unset, the default is based on the apiservers.config.openshift.io/cluster resource.
759-
// Note that only Old and Intermediate profiles are currently supported, and
760-
// the maximum available minTLSVersion is VersionTLS12.
764+
// tlsSecurityProfile configures TLS settings for the kubelet.
765+
// If unset, defaults to the apiservers.config.openshift.io/cluster resource.
766+
// Only Old and Intermediate profiles are supported; maximum minTLSVersion is VersionTLS12.
761767
// +optional
762768
TLSSecurityProfile *configv1.TLSSecurityProfile `json:"tlsSecurityProfile,omitempty"`
763769
}

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,30 @@ 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 enabled, prevents node failure
53+
from resource starvation of system components (kubelet, CRI-O) without manual configuration.
54+
When unset or true, automatic sizing is enabled. Set to false to disable and use manual settings.
5055
type: boolean
5156
kubeletConfig:
5257
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.
58+
kubeletConfig contains upstream Kubernetes kubelet configuration fields.
59+
Values are validated by the kubelet itself. Invalid values may render nodes unusable.
60+
Refer to OpenShift documentation for the Kubernetes version corresponding to your
61+
OpenShift release to find valid kubelet configuration options.
5762
type: object
5863
x-kubernetes-preserve-unknown-fields: true
5964
logLevel:
65+
description: |-
66+
logLevel sets the kubelet log verbosity. Higher values increase log detail.
67+
Defaults to 2 if unset.
6068
format: int32
6169
type: integer
6270
machineConfigPoolSelector:
6371
description: |-
64-
machineConfigPoolSelector selects which pools the KubeletConfig shoud apply to.
65-
A nil selector will result in no pools being selected.
72+
machineConfigPoolSelector selects which pools the KubeletConfig should apply to.
73+
A nil selector results in no pools being selected.
6674
properties:
6775
matchExpressions:
6876
description: matchExpressions is a list of label selector requirements.
@@ -109,9 +117,9 @@ spec:
109117
x-kubernetes-map-type: atomic
110118
tlsSecurityProfile:
111119
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.
120+
tlsSecurityProfile configures TLS settings for the kubelet.
121+
If unset, defaults to the apiservers.config.openshift.io/cluster resource.
122+
Only Old and Intermediate profiles are supported; maximum minTLSVersion is VersionTLS12.
115123
properties:
116124
custom:
117125
description: |-

0 commit comments

Comments
 (0)