Skip to content

Commit 88cca31

Browse files
Merge pull request #2555 from pablintino/mco-osimagestreams
MCO-1927: Add osImageStream to MCPs
2 parents 1ef028d + 3089262 commit 88cca31

File tree

30 files changed

+6501
-21
lines changed

30 files changed

+6501
-21
lines changed
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "[TechPreview] OSStreams"
3+
crdName: machineconfigpools.machineconfiguration.openshift.io
4+
featureGates:
5+
- OSStreams
6+
tests:
7+
onCreate:
8+
- name: Should be able to create a minimal MachineConfigPool
9+
initial: |
10+
apiVersion: machineconfiguration.openshift.io/v1
11+
kind: MachineConfigPool
12+
spec: {} # No spec is required for a MachineConfigPool
13+
expected: |
14+
apiVersion: machineconfiguration.openshift.io/v1
15+
kind: MachineConfigPool
16+
spec: {}
17+
- name: Should be able to select a non-default osImageStream
18+
initial: |
19+
apiVersion: machineconfiguration.openshift.io/v1
20+
kind: MachineConfigPool
21+
spec:
22+
osImageStream:
23+
name: "rhel10-coreos"
24+
expected: |
25+
apiVersion: machineconfiguration.openshift.io/v1
26+
kind: MachineConfigPool
27+
spec:
28+
osImageStream:
29+
name: "rhel10-coreos"
30+
- name: If given, the osImageStream.name must not be empty
31+
initial: |
32+
apiVersion: machineconfiguration.openshift.io/v1
33+
kind: MachineConfigPool
34+
spec:
35+
osImageStream:
36+
name: ""
37+
expectedError: "spec.osImageStream.name in body should be at least 1 chars long"
38+
- name: If given, the osImageStream.name should be composed only by lowercase alphanumeric chars, hyphens and dots
39+
initial: |
40+
apiVersion: machineconfiguration.openshift.io/v1
41+
kind: MachineConfigPool
42+
spec:
43+
osImageStream:
44+
name: "rhel10#1-coreos"
45+
expectedError: "spec.osImageStream.name: Invalid value: \"string\": a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
46+
- name: If given, the osImageStream.name must be lowercase
47+
initial: |
48+
apiVersion: machineconfiguration.openshift.io/v1
49+
kind: MachineConfigPool
50+
spec:
51+
osImageStream:
52+
name: "RHEL10-COREOS"
53+
expectedError: "spec.osImageStream.name: Invalid value: \"string\": a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
54+
- name: If given, the osImageStream.name should not exceed 253 characters
55+
initial: |
56+
apiVersion: machineconfiguration.openshift.io/v1
57+
kind: MachineConfigPool
58+
spec:
59+
osImageStream:
60+
name: "rhel-coreos32131e2ddf34f44r3r3r4f43tg54frg54tg45454g4g45gt34f43g54g45g3rhel-coreos32131e2ddf34f44r3r3r4f43tg54frg54tg45454g4g45gt34f43g54g45g3rhel-coreos32131e2ddf34f44r3r3r4f43tg54frg54tg45454g4g45gt34f43g54g45g3rhel-coreos32131e2ddf34f44r3r3r4f43tg54frg54tg"
61+
expectedError: "Too long: may not be more than 253 bytes"
62+
onUpdate:
63+
- name: If given, the osImageStream can be removed
64+
initial: |
65+
apiVersion: machineconfiguration.openshift.io/v1
66+
kind: MachineConfigPool
67+
spec:
68+
osImageStream:
69+
name: "rhel10-coreos"
70+
updated: |
71+
apiVersion: machineconfiguration.openshift.io/v1
72+
kind: MachineConfigPool
73+
spec: {}
74+
expected: |
75+
apiVersion: machineconfiguration.openshift.io/v1
76+
kind: MachineConfigPool
77+
spec: {}
78+
- name: If not present, the osImageStream can be added to the pool
79+
initial: |
80+
apiVersion: machineconfiguration.openshift.io/v1
81+
kind: MachineConfigPool
82+
spec: {}
83+
updated: |
84+
apiVersion: machineconfiguration.openshift.io/v1
85+
kind: MachineConfigPool
86+
spec:
87+
osImageStream:
88+
name: "rhel10-coreos"
89+
expected: |
90+
apiVersion: machineconfiguration.openshift.io/v1
91+
kind: MachineConfigPool
92+
spec:
93+
osImageStream:
94+
name: "rhel10-coreos"
95+
- name: Status osImageStream can be set
96+
initial: |
97+
apiVersion: machineconfiguration.openshift.io/v1
98+
kind: MachineConfigPool
99+
spec: {}
100+
status: {}
101+
updated: |
102+
apiVersion: machineconfiguration.openshift.io/v1
103+
kind: MachineConfigPool
104+
spec: {}
105+
status:
106+
osImageStream:
107+
name: "rhel10-coreos"
108+
expected: |
109+
apiVersion: machineconfiguration.openshift.io/v1
110+
kind: MachineConfigPool
111+
spec: {}
112+
status:
113+
osImageStream:
114+
name: "rhel10-coreos"
115+
- name: Status osImageStream can be updated
116+
initial: |
117+
apiVersion: machineconfiguration.openshift.io/v1
118+
kind: MachineConfigPool
119+
spec: {}
120+
status:
121+
osImageStream:
122+
name: "rhel9-coreos"
123+
updated: |
124+
apiVersion: machineconfiguration.openshift.io/v1
125+
kind: MachineConfigPool
126+
spec: {}
127+
status:
128+
osImageStream:
129+
name: "rhel10-coreos"
130+
expected: |
131+
apiVersion: machineconfiguration.openshift.io/v1
132+
kind: MachineConfigPool
133+
spec: {}
134+
status:
135+
osImageStream:
136+
name: "rhel10-coreos"
137+
- name: Status osImageStream can be removed
138+
initial: |
139+
apiVersion: machineconfiguration.openshift.io/v1
140+
kind: MachineConfigPool
141+
spec: {}
142+
status:
143+
osImageStream:
144+
name: "rhel10-coreos"
145+
updated: |
146+
apiVersion: machineconfiguration.openshift.io/v1
147+
kind: MachineConfigPool
148+
spec: {}
149+
status: {}
150+
expected: |
151+
apiVersion: machineconfiguration.openshift.io/v1
152+
kind: MachineConfigPool
153+
spec: {}
154+
status: {}
155+
- name: Status osImageStream.name must not be empty
156+
initial: |
157+
apiVersion: machineconfiguration.openshift.io/v1
158+
kind: MachineConfigPool
159+
spec: {}
160+
status: {}
161+
updated: |
162+
apiVersion: machineconfiguration.openshift.io/v1
163+
kind: MachineConfigPool
164+
spec: {}
165+
status:
166+
osImageStream:
167+
name: ""
168+
expectedStatusError: "status.osImageStream.name: Invalid value: \"\": osImageStream.name in body should be at least 1 chars long"
169+
- name: Status osImageStream.name should be composed only by lowercase alphanumeric chars, hyphens and dots
170+
initial: |
171+
apiVersion: machineconfiguration.openshift.io/v1
172+
kind: MachineConfigPool
173+
spec: {}
174+
status: {}
175+
updated: |
176+
apiVersion: machineconfiguration.openshift.io/v1
177+
kind: MachineConfigPool
178+
spec: {}
179+
status:
180+
osImageStream:
181+
name: "rhel10#1-coreos"
182+
expectedStatusError: "status.osImageStream.name: Invalid value: \"string\": a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
183+
- name: Status osImageStream.name must be lowercase
184+
initial: |
185+
apiVersion: machineconfiguration.openshift.io/v1
186+
kind: MachineConfigPool
187+
spec: {}
188+
status: {}
189+
updated: |
190+
apiVersion: machineconfiguration.openshift.io/v1
191+
kind: MachineConfigPool
192+
spec: {}
193+
status:
194+
osImageStream:
195+
name: "RHEL10-COREOS"
196+
expectedStatusError: "status.osImageStream.name: Invalid value: \"string\": a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
197+
- name: Status osImageStream.name should not exceed 253 characters
198+
initial: |
199+
apiVersion: machineconfiguration.openshift.io/v1
200+
kind: MachineConfigPool
201+
spec: {}
202+
status: {}
203+
updated: |
204+
apiVersion: machineconfiguration.openshift.io/v1
205+
kind: MachineConfigPool
206+
spec: {}
207+
status:
208+
osImageStream:
209+
name: "rhel-coreos32131e2ddf34f44r3r3r4f43tg54frg54tg45454g4g45gt34f43g54g45g3rhel-coreos32131e2ddf34f44r3r3r4f43tg54frg54tg45454g4g45gt34f43g54g45g3rhel-coreos32131e2ddf34f44r3r3r4f43tg54frg54tg45454g4g45gt34f43g54g45g3rhel-coreos32131e2ddf34f44r3r3r4f43tg54frg54tg"
210+
expectedStatusError: "Too long: may not be more than 253 bytes"

machineconfiguration/v1/types.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,34 @@ type MachineConfigPoolSpec struct {
452452
// +listMapKey=name
453453
// +kubebuilder:validation:MaxItems=100
454454
PinnedImageSets []PinnedImageSetRef `json:"pinnedImageSets,omitempty"`
455+
456+
// osImageStream specifies an OS stream to be used for the pool.
457+
//
458+
// This field can be optionally set to a known OSImageStream name to change the
459+
// OS and Extension images with a well-known, tested, release-provided set of images.
460+
// This enables a streamlined way of switching the pool's node OS to a different version
461+
// than the cluster default, such as transitioning to a major RHEL version.
462+
//
463+
// When set, the referenced stream overrides the cluster-wide OS
464+
// images for the pool with the OS and Extensions associated to stream.
465+
// When omitted, the pool uses the cluster-wide default OS images.
466+
//
467+
// +openshift:enable:FeatureGate=OSStreams
468+
// +optional
469+
OSImageStream OSImageStreamReference `json:"osImageStream,omitempty,omitzero"`
470+
}
471+
472+
type OSImageStreamReference struct {
473+
// name is a required reference to an OSImageStream to be used for the pool.
474+
//
475+
// It must be a valid RFC 1123 subdomain between 1 and 253 characters in length,
476+
// consisting of lowercase alphanumeric characters, hyphens ('-'), and periods ('.').
477+
//
478+
// +required
479+
// +kubebuilder:validation:MinLength=1
480+
// +kubebuilder:validation:MaxLength=253
481+
// +kubebuilder:validation:XValidation:rule="!format.dns1123Subdomain().validate(self).hasValue()",message="a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
482+
Name string `json:"name,omitempty"`
455483
}
456484

457485
type PinnedImageSetRef struct {
@@ -517,6 +545,13 @@ type MachineConfigPoolStatus struct {
517545
// +listMapKey=poolSynchronizerType
518546
// +optional
519547
PoolSynchronizersStatus []PoolSynchronizerStatus `json:"poolSynchronizersStatus,omitempty"`
548+
549+
// osImageStream specifies the last updated OSImageStream for the pool.
550+
//
551+
// When omitted, the pool is using the cluster-wide default OS images.
552+
// +openshift:enable:FeatureGate=OSStreams
553+
// +optional
554+
OSImageStream OSImageStreamReference `json:"osImageStream,omitempty,omitzero"`
520555
}
521556

522557
// +kubebuilder:validation:XValidation:rule="self.machineCount >= self.updatedMachineCount", message="machineCount must be greater than or equal to updatedMachineCount"

0 commit comments

Comments
 (0)