Skip to content

Commit 0216bc1

Browse files
committed
pis to v1
1 parent 8a7efbf commit 0216bc1

11 files changed

+743
-1
lines changed

hack/update-payload-crds.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ crd_globs="\
2222
operator/v1/zz_generated.crd-manifests/0000_25_kube-controller-manager_01_kubecontrollermanagers*.crd.yaml
2323
config/v1/zz_generated.crd-manifests/0000_10_openshift-controller-manager_01_builds*.crd.yaml
2424
operator/v1/zz_generated.crd-manifests/0000_50_openshift-controller-manager_02_openshiftcontrollermanagers*.crd.yaml
25-
machineconfiguration/v1/zz_generated.crd-manifests/*.crd.yaml
25+
machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_containerruntimeconfigs*.crd.yaml
26+
machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_controllerconfigs*.crd.yaml
27+
machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_kubeletconfigs*.crd.yaml
28+
machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_machineconfigpools*.crd.yaml
29+
machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_machineconfigs*.crd.yaml
30+
machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_machineosbuilds*.crd.yaml
31+
machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_machineosconfigs*.crd.yaml
2632
machineconfiguration/v1alpha1/zz_generated.crd-manifests/0000_80_machine-config_01_machineconfignodes*.crd.yaml
2733
machineconfiguration/v1alpha1/zz_generated.crd-manifests/0000_80_machine-config_01_pinnedimagesets*.crd.yaml
2834
operator/v1/zz_generated.crd-manifests/0000_80_machine-config_01_machineconfigurations*.crd.yaml

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,86 @@
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+
// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/2198
13+
// +openshift:file-pattern=cvoRunLevel=0000_80,operatorName=machine-config,operatorOrdering=01
14+
// +openshift:enable:FeatureGate=PinnedImages
15+
// +kubebuilder:metadata:labels=openshift.io/operator-managed=
16+
17+
// PinnedImageSet describes a set of images that should be pinned by CRI-O and
18+
// pulled to the nodes which are members of the declared MachineConfigPools.
19+
//
20+
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
21+
// +openshift:compatibility-gen:level=1
22+
type PinnedImageSet struct {
23+
metav1.TypeMeta `json:",inline"`
24+
25+
// metadata is the standard object metadata.
26+
// +optional
27+
metav1.ObjectMeta `json:"metadata,omitempty"`
28+
29+
// spec describes the configuration of this pinned image set.
30+
// +required
31+
Spec PinnedImageSetSpec `json:"spec"`
32+
}
33+
34+
// PinnedImageSetSpec defines the desired state of a PinnedImageSet.
35+
type PinnedImageSetSpec struct {
36+
// pinnedImages is a list of OCI Image referenced by digest that should be
37+
// pinned and pre-loaded by the nodes of a MachineConfigPool.
38+
// Translates into a new file inside the /etc/crio/crio.conf.d directory
39+
// with content similar to this:
40+
//
41+
// pinned_images = [
42+
// "quay.io/openshift-release-dev/ocp-release@sha256:...",
43+
// "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:...",
44+
// "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:...",
45+
// ...
46+
// ]
47+
//
48+
// Image references must be by digest.
49+
// A maximum of 500 images may be specified.
50+
// +required
51+
// +kubebuilder:validation:MinItems=1
52+
// +kubebuilder:validation:MaxItems=500
53+
// +listType=map
54+
// +listMapKey=name
55+
PinnedImages []PinnedImageRef `json:"pinnedImages"`
56+
}
57+
58+
// PinnedImageRef represents a reference to an OCI image
59+
type PinnedImageRef struct {
60+
// name is an OCI Image referenced by digest.
61+
// The format of the image pull spec is: host[:port][/namespace]/name@sha256:<digest>,
62+
// where the digest must be 64 characters long, and consist only of lowercase hexadecimal characters, a-f and 0-9.
63+
// The length of the whole spec must be between 1 to 447 characters.
64+
// +required
65+
Name ImageDigestFormat `json:"name"`
66+
}
67+
68+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
69+
70+
// PinnedImageSetList is a list of PinnedImageSet resources
71+
//
72+
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
73+
// +openshift:compatibility-gen:level=1
74+
type PinnedImageSetList struct {
75+
metav1.TypeMeta `json:",inline"`
76+
77+
// metadata is the standard list metadata.
78+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
79+
// +optional
80+
metav1.ListMeta `json:"metadata,omitempty"`
81+
82+
// items contains a collection of PinnedImageSet resources.
83+
// +kubebuilder:validation:MaxItems=500
84+
// +optional
85+
Items []PinnedImageSet `json:"items"`
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+
A maximum of 500 images may be specified.
67+
items:
68+
description: PinnedImageRef represents a reference to an OCI image
69+
properties:
70+
name:
71+
description: |-
72+
name is an OCI Image referenced by digest.
73+
The format of the image pull spec is: host[:port][/namespace]/name@sha256:<digest>,
74+
where the digest must be 64 characters long, and consist only of lowercase hexadecimal characters, a-f and 0-9.
75+
The length of the whole spec must be between 1 to 447 characters.
76+
maxLength: 447
77+
minLength: 1
78+
type: string
79+
x-kubernetes-validations:
80+
- message: the OCI Image reference must end with a valid '@sha256:<digest>'
81+
suffix, where '<digest>' is 64 characters long
82+
rule: (self.split('@').size() == 2 && self.split('@')[1].matches('^sha256:[a-f0-9]{64}$'))
83+
- message: the OCI Image name should follow the host[:port][/namespace]/name
84+
format, resembling a valid URL without the scheme
85+
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-_.]*?$'))
86+
required:
87+
- name
88+
type: object
89+
maxItems: 500
90+
minItems: 1
91+
type: array
92+
x-kubernetes-list-map-keys:
93+
- name
94+
x-kubernetes-list-type: map
95+
required:
96+
- pinnedImages
97+
type: object
98+
required:
99+
- spec
100+
type: object
101+
served: true
102+
storage: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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: DevPreviewNoUpgrade
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+
A maximum of 500 images may be specified.
67+
items:
68+
description: PinnedImageRef represents a reference to an OCI image
69+
properties:
70+
name:
71+
description: |-
72+
name is an OCI Image referenced by digest.
73+
The format of the image pull spec is: host[:port][/namespace]/name@sha256:<digest>,
74+
where the digest must be 64 characters long, and consist only of lowercase hexadecimal characters, a-f and 0-9.
75+
The length of the whole spec must be between 1 to 447 characters.
76+
maxLength: 447
77+
minLength: 1
78+
type: string
79+
x-kubernetes-validations:
80+
- message: the OCI Image reference must end with a valid '@sha256:<digest>'
81+
suffix, where '<digest>' is 64 characters long
82+
rule: (self.split('@').size() == 2 && self.split('@')[1].matches('^sha256:[a-f0-9]{64}$'))
83+
- message: the OCI Image name should follow the host[:port][/namespace]/name
84+
format, resembling a valid URL without the scheme
85+
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-_.]*?$'))
86+
required:
87+
- name
88+
type: object
89+
maxItems: 500
90+
minItems: 1
91+
type: array
92+
x-kubernetes-list-map-keys:
93+
- name
94+
x-kubernetes-list-type: map
95+
required:
96+
- pinnedImages
97+
type: object
98+
required:
99+
- spec
100+
type: object
101+
served: true
102+
storage: true

0 commit comments

Comments
 (0)