Skip to content

Commit af05ca1

Browse files
committed
MCO-1927: Add OSImageStream v1alpha1 API
Introduces OSImageStream as a catalog resource that enables discovery of available OS image streams for MachineConfigPools. The resource is populated by the MachineConfigOperator from release metadata and provides OS and OS Extensions image URLs referenced by digest. The change adds the the osImageStream field to MachineConfigPoolSpec, allowing individual pools to override cluster-wide OS images with a specific OS stream. The field is optional and gated behind the OSStreams feature gate. When omitted, pools use the cluster-wide default OS images.
1 parent 4646bbb commit af05ca1

File tree

26 files changed

+6229
-39302
lines changed

26 files changed

+6229
-39302
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 lowercase 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 lowercase 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 lowercase 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 lowercase 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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,29 @@ 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+
// When set, the referenced stream overrides the cluster-wide OS
459+
// images for the pool with the OS and Extensions associated to stream.
460+
// When omitted, the pool uses the cluster-wide default OS images.
461+
//
462+
// +openshift:enable:FeatureGate=OSStreams
463+
// +optional
464+
OSImageStream OSImageStreamReference `json:"osImageStream,omitempty,omitzero"`
465+
}
466+
467+
type OSImageStreamReference struct {
468+
// name is a reference to an OSImageStream stream to be used for the pool.
469+
//
470+
// This value should be between 1 and 253 characters, and must contain only lowercase
471+
// alphanumeric characters, hyphens and periods, and should start and end with an alphanumeric character.
472+
//
473+
// +required
474+
// +kubebuilder:validation:MinLength:=1
475+
// +kubebuilder:validation:MaxLength:=253
476+
// +kubebuilder:validation:XValidation:rule="!format.dns1123Subdomain().validate(self).hasValue()",message="a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
477+
Name string `json:"name,omitempty"`
455478
}
456479

457480
type PinnedImageSetRef struct {
@@ -517,6 +540,13 @@ type MachineConfigPoolStatus struct {
517540
// +listMapKey=poolSynchronizerType
518541
// +optional
519542
PoolSynchronizersStatus []PoolSynchronizerStatus `json:"poolSynchronizersStatus,omitempty"`
543+
544+
// osImageStream specifies the last updated OSImageStream stream for the pool.
545+
//
546+
// When omitted, the pool is using the cluster-wide default OS images.
547+
// +openshift:enable:FeatureGate=OSStreams
548+
// +optional
549+
OSImageStream OSImageStreamReference `json:"osImageStream,omitempty,omitzero"`
520550
}
521551

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

0 commit comments

Comments
 (0)