Skip to content

Commit cbe1738

Browse files
committed
MCO-1927: Add osImageStream to MCPs
Adds 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 cbe1738

File tree

24 files changed

+5864
-0
lines changed

24 files changed

+5864
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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: "rhel10-coreos"
23+
expected: |
24+
apiVersion: machineconfiguration.openshift.io/v1
25+
kind: MachineConfigPool
26+
spec:
27+
osImageStream: "rhel10-coreos"
28+
- name: If given, the osImageStream must be non-empty
29+
initial: |
30+
apiVersion: machineconfiguration.openshift.io/v1
31+
kind: MachineConfigPool
32+
spec:
33+
osImageStream: ""
34+
expectedError: "spec.osImageStream in body should be at least 1 chars long"
35+
- name: If given, the osImageStream should be composed only by alphanumeric chars, hyphens and dots
36+
initial: |
37+
apiVersion: machineconfiguration.openshift.io/v1
38+
kind: MachineConfigPool
39+
spec:
40+
osImageStream: "rhel10#1-coreos"
41+
expectedError: "spec.osImageStream: Invalid value: \"string\": The osImageStream must start with a letter and contain only alphanumeric characters, hyphens ('-'), and dots ('.')."
42+
- name: If given, the osImageStream should not exceed 70 characters
43+
initial: |
44+
apiVersion: machineconfiguration.openshift.io/v1
45+
kind: MachineConfigPool
46+
spec:
47+
osImageStream: "rhel-coreos32131e2ddf34f44r3r3r4f43tg54frg54tg45454g4g45gt34f43g54g45g3"
48+
expectedError: "Too long: may not be more than 70 bytes"
49+
onUpdate:
50+
- name: If given, the osImageStream can be removed
51+
initial: |
52+
apiVersion: machineconfiguration.openshift.io/v1
53+
kind: MachineConfigPool
54+
spec:
55+
osImageStream: "rhel10-coreos"
56+
updated: |
57+
apiVersion: machineconfiguration.openshift.io/v1
58+
kind: MachineConfigPool
59+
spec: {}
60+
expected: |
61+
apiVersion: machineconfiguration.openshift.io/v1
62+
kind: MachineConfigPool
63+
spec: {}
64+
- name: If not present, the osImageStream can be added to the pool
65+
initial: |
66+
apiVersion: machineconfiguration.openshift.io/v1
67+
kind: MachineConfigPool
68+
spec: {}
69+
updated: |
70+
apiVersion: machineconfiguration.openshift.io/v1
71+
kind: MachineConfigPool
72+
spec:
73+
osImageStream: "rhel10-coreos"
74+
expected: |
75+
apiVersion: machineconfiguration.openshift.io/v1
76+
kind: MachineConfigPool
77+
spec:
78+
osImageStream: "rhel10-coreos"

machineconfiguration/v1/types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,22 @@ 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, this value overrides the cluster-wide OS images for the pool with
459+
// the OS and Extensions associated to the specified stream.
460+
// When omitted or empty, the pool uses the cluster-wide default OS images.
461+
//
462+
// The stream name must start with a letter and contain only alphanumeric
463+
// characters, hyphens ('-'), and dots ('.'), with a maximum length of 70 characters.
464+
//
465+
// +optional
466+
// +openshift:enable:FeatureGate=OSStreams
467+
// +kubebuilder:validation:MinLength=1
468+
// +kubebuilder:validation:MaxLength=70
469+
// +kubebuilder:validation:XValidation:rule=`self.matches('^[a-zA-Z][a-zA-Z0-9.-]*$')`,message="The osImageStream must start with a letter and contain only alphanumeric characters, hyphens ('-'), and dots ('.')."
470+
OSImageStream string `json:"osImageStream,omitempty"`
455471
}
456472

457473
type PinnedImageSetRef struct {

0 commit comments

Comments
 (0)