Skip to content

Commit eb17df7

Browse files
committed
machineconfiguration/v1alpha1: add InternalReleaseImage
1 parent f4cd2bb commit eb17df7

File tree

34 files changed

+6867
-8
lines changed

34 files changed

+6867
-8
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "[TechPreview] InternalReleaseImage"
3+
crdName: machineconfignodes.machineconfiguration.openshift.io
4+
featureGates:
5+
- MachineConfigNodes
6+
- NoRegistryClusterOperations
7+
tests:
8+
onUpdate:
9+
- name: Should be able to update a MachineConfigNode with a minimal internalReleaseImage status field.
10+
initial: |
11+
apiVersion: machineconfiguration.openshift.io/v1
12+
kind: MachineConfigNode
13+
metadata:
14+
name: foobar
15+
spec:
16+
node:
17+
name: foobar
18+
pool:
19+
name: master
20+
configVersion:
21+
desired: rendered-master-abc
22+
updated: |
23+
apiVersion: machineconfiguration.openshift.io/v1
24+
kind: MachineConfigNode
25+
metadata:
26+
name: foobar
27+
spec:
28+
node:
29+
name: foobar
30+
pool:
31+
name: master
32+
configVersion:
33+
desired: rendered-master-abc
34+
status:
35+
internalReleaseImage:
36+
installedReleases:
37+
- name: ocp-release-bundle-4.18.0-x86_64
38+
image: example.com/example/openshift-release-dev@sha256:d98795f7932441b30bb8bcfbbf05912875383fad1f2b3be08a22ec148d68607f
39+
expected: |
40+
apiVersion: machineconfiguration.openshift.io/v1
41+
kind: MachineConfigNode
42+
metadata:
43+
name: foobar
44+
spec:
45+
node:
46+
name: foobar
47+
pool:
48+
name: master
49+
configVersion:
50+
desired: rendered-master-abc
51+
status:
52+
internalReleaseImage:
53+
installedReleases:
54+
- name: ocp-release-bundle-4.18.0-x86_64
55+
image: example.com/example/openshift-release-dev@sha256:d98795f7932441b30bb8bcfbbf05912875383fad1f2b3be08a22ec148d68607f

machineconfiguration/v1/types_machineconfignode.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,78 @@ type MachineConfigNodeStatus struct {
158158
// +kubebuilder:validation:MaxItems=32
159159
// +optional
160160
IrreconcilableChanges []IrreconcilableChangeDiff `json:"irreconcilableChanges,omitempty"`
161+
// internalReleaseImage describes the status of the release payloads stored in the node.
162+
// When specified, an internalReleaseImage custom resource exists on the cluster, and the specified images will be made available on the control plane nodes.
163+
// This field will reflect the actual on-disk state of those release images.
164+
// +openshift:enable:FeatureGate=NoRegistryClusterOperations
165+
// +optional
166+
InternalReleaseImage MachineConfigNodeStatusInternalReleaseImage `json:"internalReleaseImage,omitzero,omitempty"`
167+
}
168+
169+
// MachineConfigNodeStatusInternalReleaseImage holds information about the current and discovered release bundles for the observed machine
170+
// config node.
171+
type MachineConfigNodeStatusInternalReleaseImage struct {
172+
// releases is a list of the release bundles currently owned and managed by the
173+
// cluster, indicating that their images can be safely pulled by any cluster entity
174+
// requiring them.
175+
// This field can contain between 1 and 5 entries.
176+
// +listType=map
177+
// +listMapKey=name
178+
// +kubebuilder:validation:MinItems=1
179+
// +kubebuilder:validation:MaxItems=5
180+
// +required
181+
Releases []MachineConfigNodeStatusInternalReleaseImageRef `json:"releases,omitempty"`
161182
}
162183

184+
// MachineConfigNodeStatusInternalReleaseImageRef is used to provide a more detailed reference for
185+
// a release bundle.
186+
// +openshift:enable:FeatureGate=NoRegistryClusterOperations
187+
type MachineConfigNodeStatusInternalReleaseImageRef struct {
188+
// conditions represent the observations of an internal release image current state. See InternalReleaseImageConditionType for the possible
189+
// type values.
190+
// +listType=map
191+
// +listMapKey=type
192+
// +kubebuilder:validation:MinItems=1
193+
// +kubebuilder:validation:MaxItems=5
194+
// +optional
195+
Conditions []metav1.Condition `json:"conditions,omitempty"`
196+
// name indicates the desired release bundle identifier. This field is required and must be between 1 and 64 characters long.
197+
// +kubebuilder:validation:MinLength=1
198+
// +kubebuilder:validation:MaxLength=64
199+
// +required
200+
Name string `json:"name,omitempty"`
201+
// image is an OCP release image referenced by digest.
202+
// The format of the image pull spec is: host[:port][/namespace]/name@sha256:<digest>,
203+
// where the digest must be 64 characters long, and consist only of lowercase hexadecimal characters, a-f and 0-9.
204+
// The length of the whole spec must be between 1 to 447 characters.
205+
// +kubebuilder:validation:MinLength=1
206+
// +kubebuilder:validation:MaxLength=447
207+
// +kubebuilder:validation:XValidation:rule=`(self.split('@').size() == 2 && self.split('@')[1].matches('^sha256:[a-f0-9]{64}$'))`,message="the OCI Image reference must end with a valid '@sha256:<digest>' suffix, where '<digest>' is 64 characters long"
208+
// +kubebuilder:validation:XValidation:rule=`(self.split('@')[0].matches('^([a-zA-Z0-9-]+\\.)+[a-zA-Z0-9-]+(:[0-9]{2,5})?/([a-zA-Z0-9-_]{0,61}/)?[a-zA-Z0-9-_.]*?$'))`,message="the OCI Image name should follow the host[:port][/namespace]/name format, resembling a valid URL without the scheme"
209+
// +required
210+
Image string `json:"image,omitempty"`
211+
}
212+
213+
// InternalReleaseImageConditionType is each possible state for each possible MachineConfigNodeStatusInternalReleaseImageRef
214+
// conditions type.
215+
// +enum
216+
type InternalReleaseImageConditionType string
217+
218+
const (
219+
// InternalReleaseImageConditionTypeMounted describes a new release, not yet installed, that has been discovered when an ISO has been attached to
220+
// the current node
221+
InternalReleaseImageConditionTypeMounted InternalReleaseImageConditionType = "Mounted"
222+
// InternalReleaseImageConditionTypeInstalling describes a new release that is getting installed on the current node. Due the size of the data
223+
// transfered, the operation could take several minutes
224+
InternalReleaseImageConditionTypeInstalling InternalReleaseImageConditionType = "Installing"
225+
// InternalReleaseImageConditionTypeAvailable describes a release that has been successfully installed on the current node, ready to be consumed
226+
InternalReleaseImageConditionTypeAvailable InternalReleaseImageConditionType = "Available"
227+
// InternalReleaseImageConditionTypeRemoving describes an existing release that is getting removed from the current node
228+
InternalReleaseImageConditionTypeRemoving InternalReleaseImageConditionType = "Removing"
229+
// InternalReleaseImageConditionTypeDegraded describes a failure for the current release
230+
InternalReleaseImageConditionTypeDegraded InternalReleaseImageConditionType = "Degraded"
231+
)
232+
163233
// IrreconcilableChangeDiff holds an individual diff between the initial install-time MachineConfig
164234
// and the latest applied one caused by the presence of irreconcilable changes.
165235
type IrreconcilableChangeDiff struct {

0 commit comments

Comments
 (0)