Skip to content

Commit 4e8cd3e

Browse files
committed
pis to v1
1 parent 8a7efbf commit 4e8cd3e

10 files changed

+1058
-0
lines changed

machineconfiguration/v1/register.go

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
3838
&MachineOSConfigList{},
3939
&MachineOSBuild{},
4040
&MachineOSBuildList{},
41+
&PinnedImageSet{},
42+
&PinnedImageSetList{},
4143
)
4244

4345
metav1.AddToGroupVersion(scheme, GroupVersion)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "PinnedImageSet"
3+
crdName: pinnedimagesets.machineconfiguration.openshift.io
4+
featureGate: PinnedImages
5+
tests:
6+
onCreate:
7+
- name: Should be able to create a minimal PinnedImageSet
8+
initial: |
9+
apiVersion: machineconfiguration.openshift.io/v1
10+
kind: PinnedImageSet
11+
metadata:
12+
name: foobar
13+
labels:
14+
machineconfiguration.openshift.io/role: "master"
15+
spec:
16+
pinnedImages:
17+
- name: registry.example.com/custom-os-image@sha256:86d26e7ebcccd6f07a75db5b1e56283b25c2ee1c6a755d6ffc5a4d59beb9c504
18+
expected: |
19+
apiVersion: machineconfiguration.openshift.io/v1
20+
kind: PinnedImageSet
21+
metadata:
22+
name: foobar
23+
labels:
24+
machineconfiguration.openshift.io/role: "master"
25+
spec:
26+
pinnedImages:
27+
- name: registry.example.com/custom-os-image@sha256:86d26e7ebcccd6f07a75db5b1e56283b25c2ee1c6a755d6ffc5a4d59beb9c504
28+
- name: Should be able to create a PinnedImageSet with the PinnedImageRef name containing a port
29+
initial: |
30+
apiVersion: machineconfiguration.openshift.io/v1
31+
kind: PinnedImageSet
32+
metadata:
33+
name: foobar
34+
labels:
35+
machineconfiguration.openshift.io/role: "master"
36+
spec:
37+
pinnedImages:
38+
- name: registry.example.com:5000/custom-os-image@sha256:86d26e7ebcccd6f07a75db5b1e56283b25c2ee1c6a755d6ffc5a4d59beb9c504
39+
expected: |
40+
apiVersion: machineconfiguration.openshift.io/v1
41+
kind: PinnedImageSet
42+
metadata:
43+
name: foobar
44+
labels:
45+
machineconfiguration.openshift.io/role: "master"
46+
spec:
47+
pinnedImages:
48+
- name: registry.example.com:5000/custom-os-image@sha256:86d26e7ebcccd6f07a75db5b1e56283b25c2ee1c6a755d6ffc5a4d59beb9c504
49+
- name: Should be able to create a PinnedImageSet with the PinnedImageRef name containing a namespace
50+
initial: |
51+
apiVersion: machineconfiguration.openshift.io/v1
52+
kind: PinnedImageSet
53+
metadata:
54+
name: foobar
55+
labels:
56+
machineconfiguration.openshift.io/role: "master"
57+
spec:
58+
pinnedImages:
59+
- name: registry.example.com/my-namespace/custom-os-image@sha256:86d26e7ebcccd6f07a75db5b1e56283b25c2ee1c6a755d6ffc5a4d59beb9c504
60+
expected: |
61+
apiVersion: machineconfiguration.openshift.io/v1
62+
kind: PinnedImageSet
63+
metadata:
64+
name: foobar
65+
labels:
66+
machineconfiguration.openshift.io/role: "master"
67+
spec:
68+
pinnedImages:
69+
- name: registry.example.com/my-namespace/custom-os-image@sha256:86d26e7ebcccd6f07a75db5b1e56283b25c2ee1c6a755d6ffc5a4d59beb9c504
70+
- name: Fail on invalid PinnedImageRef name
71+
initial: |
72+
apiVersion: machineconfiguration.openshift.io/v1
73+
kind: PinnedImageSet
74+
metadata:
75+
name: foobar
76+
labels:
77+
machineconfiguration.openshift.io/role: "master"
78+
spec:
79+
pinnedImages:
80+
- name: foo.bar
81+
expectedError: "spec.pinnedImages[0].name: Invalid value: \"string\": the OCI Image reference must end with a valid '@sha256:<digest>' suffix, where '<digest>' is 64 characters long"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package v1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
// +genclient
8+
// +genclient:nonNamespaced
9+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
10+
// +kubebuilder:object:root=true
11+
// +kubebuilder:resource:path=pinnedimagesets,scope=Cluster
12+
// +kubebuilder:subresource:status
13+
// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/2198
14+
// +openshift:file-pattern=cvoRunLevel=0000_80,operatorName=machine-config,operatorOrdering=01
15+
// +openshift:enable:FeatureGate=PinnedImages
16+
// +kubebuilder:metadata:labels=openshift.io/operator-managed=
17+
18+
// PinnedImageSet describes a set of images that should be pinned by CRI-O and
19+
// pulled to the nodes which are members of the declared MachineConfigPools.
20+
//
21+
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
22+
// +openshift:compatibility-gen:level=1
23+
type PinnedImageSet struct {
24+
metav1.TypeMeta `json:",inline"`
25+
26+
// metadata is the standard object metadata.
27+
// +optional
28+
metav1.ObjectMeta `json:"metadata,omitempty"`
29+
30+
// spec describes the configuration of this pinned image set.
31+
// +required
32+
Spec PinnedImageSetSpec `json:"spec"`
33+
34+
// status describes the last observed state of this pinned image set.
35+
// +optional
36+
Status PinnedImageSetStatus `json:"status,omitempty"`
37+
}
38+
39+
// PinnedImageSetStatus describes the current state of a PinnedImageSet.
40+
type PinnedImageSetStatus struct {
41+
// conditions represent the observations of a pinned image set's current state.
42+
// +patchMergeKey=type
43+
// +patchStrategy=merge
44+
// +kubebuilder:validation:MaxItems=10
45+
// +listType=map
46+
// +listMapKey=type
47+
// +optional
48+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
49+
}
50+
51+
// PinnedImageSetSpec defines the desired state of a PinnedImageSet.
52+
type PinnedImageSetSpec struct {
53+
// pinnedImages is a list of OCI Image referenced by digest that should be
54+
// pinned and pre-loaded by the nodes of a MachineConfigPool.
55+
// Translates into a new file inside the /etc/crio/crio.conf.d directory
56+
// with content similar to this:
57+
//
58+
// pinned_images = [
59+
// "quay.io/openshift-release-dev/ocp-release@sha256:...",
60+
// "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:...",
61+
// "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:...",
62+
// ...
63+
// ]
64+
//
65+
// Image references must be by digest.
66+
// +required
67+
// +kubebuilder:validation:MinItems=1
68+
// +kubebuilder:validation:MaxItems=500
69+
// +listType=map
70+
// +listMapKey=name
71+
PinnedImages []PinnedImageRef `json:"pinnedImages"`
72+
}
73+
74+
// PinnedImageRef represents a reference to an OCI image
75+
type PinnedImageRef struct {
76+
// name is an OCI Image referenced by digest.
77+
// The format of the image pull spec is: host[:port][/namespace]/name@sha256:<digest>,
78+
// where the digest must be 64 characters long, and consist only of lowercase hexadecimal characters, a-f and 0-9.
79+
// The length of the whole spec must be between 1 to 447 characters.
80+
// +required
81+
Name ImageDigestFormat `json:"name"`
82+
}
83+
84+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
85+
86+
// PinnedImageSetList is a list of PinnedImageSet resources
87+
//
88+
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
89+
// +openshift:compatibility-gen:level=1
90+
type PinnedImageSetList struct {
91+
metav1.TypeMeta `json:",inline"`
92+
93+
// metadata is the standard list metadata.
94+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
95+
// +optional
96+
metav1.ListMeta `json:"metadata,omitempty"`
97+
98+
// items contains a collection of PinnedImageSet resources.
99+
// +kubebuilder:validation:MaxItems=500
100+
// +optional
101+
Items []PinnedImageSet `json:"items"`
102+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
annotations:
5+
api-approved.openshift.io: https://github.com/openshift/api/pull/2198
6+
api.openshift.io/merged-by-featuregates: "true"
7+
include.release.openshift.io/ibm-cloud-managed: "true"
8+
include.release.openshift.io/self-managed-high-availability: "true"
9+
release.openshift.io/feature-set: CustomNoUpgrade
10+
labels:
11+
openshift.io/operator-managed: ""
12+
name: pinnedimagesets.machineconfiguration.openshift.io
13+
spec:
14+
group: machineconfiguration.openshift.io
15+
names:
16+
kind: PinnedImageSet
17+
listKind: PinnedImageSetList
18+
plural: pinnedimagesets
19+
singular: pinnedimageset
20+
scope: Cluster
21+
versions:
22+
- name: v1
23+
schema:
24+
openAPIV3Schema:
25+
description: |-
26+
PinnedImageSet describes a set of images that should be pinned by CRI-O and
27+
pulled to the nodes which are members of the declared MachineConfigPools.
28+
29+
Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
30+
properties:
31+
apiVersion:
32+
description: |-
33+
APIVersion defines the versioned schema of this representation of an object.
34+
Servers should convert recognized schemas to the latest internal value, and
35+
may reject unrecognized values.
36+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
37+
type: string
38+
kind:
39+
description: |-
40+
Kind is a string value representing the REST resource this object represents.
41+
Servers may infer this from the endpoint the client submits requests to.
42+
Cannot be updated.
43+
In CamelCase.
44+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
45+
type: string
46+
metadata:
47+
type: object
48+
spec:
49+
description: spec describes the configuration of this pinned image set.
50+
properties:
51+
pinnedImages:
52+
description: |-
53+
pinnedImages is a list of OCI Image referenced by digest that should be
54+
pinned and pre-loaded by the nodes of a MachineConfigPool.
55+
Translates into a new file inside the /etc/crio/crio.conf.d directory
56+
with content similar to this:
57+
58+
pinned_images = [
59+
"quay.io/openshift-release-dev/ocp-release@sha256:...",
60+
"quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:...",
61+
"quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:...",
62+
...
63+
]
64+
65+
Image references must be by digest.
66+
items:
67+
description: PinnedImageRef represents a reference to an OCI image
68+
properties:
69+
name:
70+
description: |-
71+
name is an OCI Image referenced by digest.
72+
The format of the image pull spec is: host[:port][/namespace]/name@sha256:<digest>,
73+
where the digest must be 64 characters long, and consist only of lowercase hexadecimal characters, a-f and 0-9.
74+
The length of the whole spec must be between 1 to 447 characters.
75+
maxLength: 447
76+
minLength: 1
77+
type: string
78+
x-kubernetes-validations:
79+
- message: the OCI Image reference must end with a valid '@sha256:<digest>'
80+
suffix, where '<digest>' is 64 characters long
81+
rule: (self.split('@').size() == 2 && self.split('@')[1].matches('^sha256:[a-f0-9]{64}$'))
82+
- message: the OCI Image name should follow the host[:port][/namespace]/name
83+
format, resembling a valid URL without the scheme
84+
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-_.]*?$'))
85+
required:
86+
- name
87+
type: object
88+
maxItems: 500
89+
minItems: 1
90+
type: array
91+
x-kubernetes-list-map-keys:
92+
- name
93+
x-kubernetes-list-type: map
94+
required:
95+
- pinnedImages
96+
type: object
97+
status:
98+
description: status describes the last observed state of this pinned image
99+
set.
100+
properties:
101+
conditions:
102+
description: conditions represent the observations of a pinned image
103+
set's current state.
104+
items:
105+
description: Condition contains details for one aspect of the current
106+
state of this API Resource.
107+
properties:
108+
lastTransitionTime:
109+
description: |-
110+
lastTransitionTime is the last time the condition transitioned from one status to another.
111+
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
112+
format: date-time
113+
type: string
114+
message:
115+
description: |-
116+
message is a human readable message indicating details about the transition.
117+
This may be an empty string.
118+
maxLength: 32768
119+
type: string
120+
observedGeneration:
121+
description: |-
122+
observedGeneration represents the .metadata.generation that the condition was set based upon.
123+
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
124+
with respect to the current state of the instance.
125+
format: int64
126+
minimum: 0
127+
type: integer
128+
reason:
129+
description: |-
130+
reason contains a programmatic identifier indicating the reason for the condition's last transition.
131+
Producers of specific condition types may define expected values and meanings for this field,
132+
and whether the values are considered a guaranteed API.
133+
The value should be a CamelCase string.
134+
This field may not be empty.
135+
maxLength: 1024
136+
minLength: 1
137+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
138+
type: string
139+
status:
140+
description: status of the condition, one of True, False, Unknown.
141+
enum:
142+
- "True"
143+
- "False"
144+
- Unknown
145+
type: string
146+
type:
147+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
148+
maxLength: 316
149+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
150+
type: string
151+
required:
152+
- lastTransitionTime
153+
- message
154+
- reason
155+
- status
156+
- type
157+
type: object
158+
maxItems: 10
159+
type: array
160+
x-kubernetes-list-map-keys:
161+
- type
162+
x-kubernetes-list-type: map
163+
type: object
164+
required:
165+
- spec
166+
type: object
167+
served: true
168+
storage: true
169+
subresources:
170+
status: {}

0 commit comments

Comments
 (0)