Skip to content

Commit

Permalink
ClusterTrustBundles: Document projected volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedtd committed Nov 12, 2023
1 parent 1711494 commit 48db373
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
27 changes: 27 additions & 0 deletions content/en/docs/concepts/storage/projected-volumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Currently, the following types of volume sources can be projected:
* [`downwardAPI`](/docs/concepts/storage/volumes/#downwardapi)
* [`configMap`](/docs/concepts/storage/volumes/#configmap)
* [`serviceAccountToken`](#serviceaccounttoken)
* [`clusterTrustBundle`](#clustertrustbundle)

All sources are required to be in the same namespace as the Pod. For more details,
see the [all-in-one volume](https://git.k8s.io/design-proposals-archive/node/all-in-one-volume.md) design document.
Expand Down Expand Up @@ -70,6 +71,32 @@ A container using a projected volume source as a [`subPath`](/docs/concepts/stor
volume mount will not receive updates for those volume sources.
{{< /note >}}

## clusterTrustBundle projected volumes {#clustertrustbundle}

{{<feature-state for_k8s_version="v1.29" state="alpha" >}}

{{< note >}}
In Kubernetes {{< skew currentVersion >}}, you must enable the `ClusterTrustBundle` and `ClusterTrustBundleProjection`
[feature gates](/docs/reference/command-line-tools-reference/feature-gates/) to use this feature.
{{< /note >}}

The `clusterTrustBundle` projected volume source injects the contents of one or more ClusterTrustBundle objects as an automatically-updating file in the container filesystem.

ClusterTrustBundles can be selected either by [name](/docs/reference/access-authn-authz/certificate-signing-requests#ctb-signer-unlinked) or by [signer name](/docs/reference/access-authn-authz/certificate-signing-requests#ctb-signer-linked).

To select by name, use the `name` field to designate a single ClusterTrustBundle object.

To select by signer name, use the `signerName` and `labelSelector` fields to
designate a set of ClusterTrustBundle objects that use the given signer name.
If `labelSelector` is not present, then all ClusterTrustBundles for that signer
are selected.

In both cases, Kubelet will deduplicate all of the certificates from the selected ClusterTrustBundle objects, normalize the PEM representations (discarding comments and headers), and shuffle the order of the certificates before writing them into the file named by `path`. As the set of selected ClusterTrustBundles, or their content, changes, Kubelet will keep the file up-to-date.

By default, Kubelet will prevent the pod from starting if the named ClusterTrustBundle is not found, or if `signerName` / `labelSelector` do not match any ClusterTrustBundles. If this behavior is not desired, then set the `optional` field to `true`, and the pod will start up with an empty file at `path`.

{{% code_sample file="pods/storage/projected-clustertrusbundle.yaml" %}}

## SecurityContext interactions

The [proposal](https://git.k8s.io/enhancements/keps/sig-storage/2451-service-account-token-volumes#proposal) for file permission handling in projected service account volume enhancement introduced the projected files having the correct owner permissions set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ you like. If you want to add a note for human consumption, use the
{{< feature-state for_k8s_version="v1.27" state="alpha" >}}

{{< note >}}
In Kubernetes {{< skew currentVersion >}}, you must enable the `ClusterTrustBundles`
In Kubernetes {{< skew currentVersion >}}, you must enable the `ClusterTrustBundle`
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
_and_ the `certificates.k8s.io/v1alpha1`
{{< glossary_tooltip text="API group" term_id="api-group" >}} in order to use
Expand Down Expand Up @@ -472,6 +472,12 @@ such as role-based access control.
To distinguish them from signer-linked ClusterTrustBundles, the names of
signer-unlinked ClusterTrustBundles **must not** contain a colon (`:`).

### Accessing ClusterTrustBundles from pods {#ctb-projection}

{{<feature-state for_k8s_version="v1.29" state="alpha" >}}

The contents of ClusterTrustBundles can be injected into the container filesystem, similar to ConfigMaps and Secrets. See the [clusterTrustBundle projected volume source](/docs/concepts/storage/projected-volumes#clustertrustbundle) for more details.

<!-- TODO this should become a task page -->
## How to issue a certificate for a user {#normal-user}

Expand Down
28 changes: 28 additions & 0 deletions content/en/examples/pods/storage/projected-clustertrustbundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: Pod
metadata:
name: sa-ctb-name-test
spec:
containers:
- name: container-test
image: busybox:1.28
command: ["sleep", "3600"]
volumeMounts:
- name: token-vol
mountPath: "/root-certificates"
readOnly: true
serviceAccountName: default
volumes:
- name: root-certificates-vol
projected:
sources:
- clusterTrustBundle:
name: foo
path: foo-roots.pem
- clusterTrustBundle:
signerName: "example.com/mysigner"
labelSelector:
matchLabels:
version: live
path: mysigner-roots.pem
optional: true

0 comments on commit 48db373

Please sign in to comment.