Skip to content

Commit f598b48

Browse files
committed
copy ClusterTrustBundle API to v1beta1
1 parent 4c311c9 commit f598b48

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

pkg/apis/certificates/v1beta1/conversion.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,22 @@ import (
2424

2525
func addConversionFuncs(scheme *runtime.Scheme) error {
2626
// Add field conversion funcs.
27-
return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("CertificateSigningRequest"),
27+
err := scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("CertificateSigningRequest"),
28+
func(label, value string) (string, string, error) {
29+
switch label {
30+
case "metadata.name",
31+
"spec.signerName":
32+
return label, value, nil
33+
default:
34+
return "", "", fmt.Errorf("field label not supported: %s", label)
35+
}
36+
},
37+
)
38+
if err != nil {
39+
return err
40+
}
41+
42+
return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("ClusterTrustBundle"),
2843
func(label, value string) (string, string, error) {
2944
switch label {
3045
case "metadata.name",

staging/src/k8s.io/api/certificates/v1beta1/register.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
5151
scheme.AddKnownTypes(SchemeGroupVersion,
5252
&CertificateSigningRequest{},
5353
&CertificateSigningRequestList{},
54+
&ClusterTrustBundle{},
55+
&ClusterTrustBundleList{},
5456
)
5557

5658
// Add the watch version that applies

staging/src/k8s.io/api/certificates/v1beta1/types.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,88 @@ const (
262262
UsageMicrosoftSGC KeyUsage = "microsoft sgc"
263263
UsageNetscapeSGC KeyUsage = "netscape sgc"
264264
)
265+
266+
// +genclient
267+
// +genclient:nonNamespaced
268+
// +k8s:prerelease-lifecycle-gen:introduced=1.32
269+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
270+
271+
// ClusterTrustBundle is a cluster-scoped container for X.509 trust anchors
272+
// (root certificates).
273+
//
274+
// ClusterTrustBundle objects are considered to be readable by any authenticated
275+
// user in the cluster, because they can be mounted by pods using the
276+
// `clusterTrustBundle` projection. All service accounts have read access to
277+
// ClusterTrustBundles by default. Users who only have namespace-level access
278+
// to a cluster can read ClusterTrustBundles by impersonating a serviceaccount
279+
// that they have access to.
280+
//
281+
// It can be optionally associated with a particular assigner, in which case it
282+
// contains one valid set of trust anchors for that signer. Signers may have
283+
// multiple associated ClusterTrustBundles; each is an independent set of trust
284+
// anchors for that signer. Admission control is used to enforce that only users
285+
// with permissions on the signer can create or modify the corresponding bundle.
286+
type ClusterTrustBundle struct {
287+
metav1.TypeMeta `json:",inline"`
288+
289+
// metadata contains the object metadata.
290+
// +optional
291+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
292+
293+
// spec contains the signer (if any) and trust anchors.
294+
Spec ClusterTrustBundleSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
295+
}
296+
297+
// ClusterTrustBundleSpec contains the signer and trust anchors.
298+
type ClusterTrustBundleSpec struct {
299+
// signerName indicates the associated signer, if any.
300+
//
301+
// In order to create or update a ClusterTrustBundle that sets signerName,
302+
// you must have the following cluster-scoped permission:
303+
// group=certificates.k8s.io resource=signers resourceName=<the signer name>
304+
// verb=attest.
305+
//
306+
// If signerName is not empty, then the ClusterTrustBundle object must be
307+
// named with the signer name as a prefix (translating slashes to colons).
308+
// For example, for the signer name `example.com/foo`, valid
309+
// ClusterTrustBundle object names include `example.com:foo:abc` and
310+
// `example.com:foo:v1`.
311+
//
312+
// If signerName is empty, then the ClusterTrustBundle object's name must
313+
// not have such a prefix.
314+
//
315+
// List/watch requests for ClusterTrustBundles can filter on this field
316+
// using a `spec.signerName=NAME` field selector.
317+
//
318+
// +optional
319+
SignerName string `json:"signerName,omitempty" protobuf:"bytes,1,opt,name=signerName"`
320+
321+
// trustBundle contains the individual X.509 trust anchors for this
322+
// bundle, as PEM bundle of PEM-wrapped, DER-formatted X.509 certificates.
323+
//
324+
// The data must consist only of PEM certificate blocks that parse as valid
325+
// X.509 certificates. Each certificate must include a basic constraints
326+
// extension with the CA bit set. The API server will reject objects that
327+
// contain duplicate certificates, or that use PEM block headers.
328+
//
329+
// Users of ClusterTrustBundles, including Kubelet, are free to reorder and
330+
// deduplicate certificate blocks in this file according to their own logic,
331+
// as well as to drop PEM block headers and inter-block data.
332+
TrustBundle string `json:"trustBundle" protobuf:"bytes,2,opt,name=trustBundle"`
333+
}
334+
335+
// +k8s:prerelease-lifecycle-gen:introduced=1.32
336+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
337+
338+
// ClusterTrustBundleList is a collection of ClusterTrustBundle objects
339+
type ClusterTrustBundleList struct {
340+
metav1.TypeMeta `json:",inline"`
341+
342+
// metadata contains the list metadata.
343+
//
344+
// +optional
345+
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
346+
347+
// items is a collection of ClusterTrustBundle objects
348+
Items []ClusterTrustBundle `json:"items" protobuf:"bytes,2,rep,name=items"`
349+
}

0 commit comments

Comments
 (0)