Skip to content

Commit 5886a58

Browse files
committed
Upgrade ClusterImagePolicy and ImagePolicy to v1
Upgrade ClusterImagePolicy and ImagePolicy under SigstoreVerification featuregate to v1. will workon upgrade controller code to use v1 API and promote the featuregate to default as next step. Signed-off-by: Qi Wang <[email protected]>
1 parent 9e29d16 commit 5886a58

22 files changed

+7679
-42
lines changed

config/v1/tests/clusterimagepolicies.config.openshift.io/SigstoreImageVerification.yaml

Lines changed: 453 additions & 0 deletions
Large diffs are not rendered by default.

config/v1/tests/clusterimagepolicies.config.openshift.io/SigstoreImageVerificationPKI.yaml

Lines changed: 117 additions & 0 deletions
Large diffs are not rendered by default.

config/v1/tests/imagepolicies.config.openshift.io/SigstoreImageVerification.yaml

Lines changed: 453 additions & 0 deletions
Large diffs are not rendered by default.

config/v1/tests/imagepolicies.config.openshift.io/SigstoreImageVerificationPKI.yaml

Lines changed: 117 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package v1
2+
3+
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4+
5+
// +genclient
6+
// +genclient:nonNamespaced
7+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
8+
9+
// ClusterImagePolicy holds cluster-wide configuration for image signature verification
10+
//
11+
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
12+
// +kubebuilder:object:root=true
13+
// +kubebuilder:resource:path=clusterimagepolicies,scope=Cluster
14+
// +kubebuilder:subresource:status
15+
// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/2310
16+
// +openshift:file-pattern=cvoRunLevel=0000_10,operatorName=config-operator,operatorOrdering=01
17+
// +openshift:enable:FeatureGate=SigstoreImageVerification
18+
// +openshift:compatibility-gen:level=1
19+
type ClusterImagePolicy struct {
20+
metav1.TypeMeta `json:",inline"`
21+
22+
// metadata is the standard object's metadata.
23+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
24+
// +optional
25+
metav1.ObjectMeta `json:"metadata,omitempty"`
26+
27+
// spec contains the configuration for the cluster image policy.
28+
// +required
29+
Spec ClusterImagePolicySpec `json:"spec"`
30+
// status contains the observed state of the resource.
31+
// +optional
32+
Status ClusterImagePolicyStatus `json:"status,omitempty"`
33+
}
34+
35+
// CLusterImagePolicySpec is the specification of the ClusterImagePolicy custom resource.
36+
type ClusterImagePolicySpec struct {
37+
// scopes defines the list of image identities assigned to a policy. Each item refers to a scope in a registry implementing the "Docker Registry HTTP API V2".
38+
// Scopes matching individual images are named Docker references in the fully expanded form, either using a tag or digest. For example, docker.io/library/busybox:latest (not busybox:latest).
39+
// More general scopes are prefixes of individual-image scopes, and specify a repository (by omitting the tag or digest), a repository
40+
// namespace, or a registry host (by only specifying the host name and possibly a port number) or a wildcard expression starting with `*.`, for matching all subdomains (not including a port number).
41+
// Wildcards are only supported for subdomain matching, and may not be used in the middle of the host, i.e. *.example.com is a valid case, but example*.*.com is not.
42+
// If multiple scopes match a given image, only the policy requirements for the most specific scope apply. The policy requirements for more general scopes are ignored.
43+
// In addition to setting a policy appropriate for your own deployed applications, make sure that a policy on the OpenShift image repositories
44+
// quay.io/openshift-release-dev/ocp-release, quay.io/openshift-release-dev/ocp-v4.0-art-dev (or on a more general scope) allows deployment of the OpenShift images required for cluster operation.
45+
// If a scope is configured in both the ClusterImagePolicy and the ImagePolicy, or if the scope in ImagePolicy is nested under one of the scopes from the ClusterImagePolicy, only the policy from the ClusterImagePolicy will be applied.
46+
// For additional details about the format, please refer to the document explaining the docker transport field,
47+
// which can be found at: https://github.com/containers/image/blob/main/docs/containers-policy.json.5.md#docker
48+
// +required
49+
// +kubebuilder:validation:MaxItems=256
50+
// +listType=set
51+
Scopes []ImageScope `json:"scopes"`
52+
// policy contains configuration to allow scopes to be verified, and defines how
53+
// images not matching the verification policy will be treated.
54+
// +required
55+
Policy Policy `json:"policy"`
56+
}
57+
58+
// +k8s:deepcopy-gen=true
59+
type ClusterImagePolicyStatus struct {
60+
// conditions provide details on the status of this API Resource.
61+
// +kubebuilder:validation:MaxItems=100
62+
// +listType=map
63+
// +listMapKey=type
64+
// +optional
65+
Conditions []metav1.Condition `json:"conditions,omitempty"`
66+
}
67+
68+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
69+
70+
// ClusterImagePolicyList is a list of ClusterImagePolicy 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 ClusterImagePolicyList struct {
75+
metav1.TypeMeta `json:",inline"`
76+
77+
// metadata is the standard list's metadata.
78+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
79+
// +required
80+
metav1.ListMeta `json:"metadata"`
81+
82+
// items is a list of ClusterImagePolices
83+
// +kubebuilder:validation:MaxItems=1000
84+
// +required
85+
Items []ClusterImagePolicy `json:"items"`
86+
}

0 commit comments

Comments
 (0)