Skip to content

Commit ee1fa43

Browse files
authored
Merge pull request #46544 from my-git9/pt-10139
improve format for bootstrap-tokens certificate-signing-requests
2 parents 172fb26 + 7215e39 commit ee1fa43

File tree

2 files changed

+53
-50
lines changed

2 files changed

+53
-50
lines changed

content/en/docs/reference/access-authn-authz/bootstrap-tokens.md

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@ weight: 20
1111
{{< feature-state for_k8s_version="v1.18" state="stable" >}}
1212

1313
Bootstrap tokens are a simple bearer token that is meant to be used when
14-
creating new clusters or joining new nodes to an existing cluster. It was built
15-
to support [kubeadm](/docs/reference/setup-tools/kubeadm/), but can be used in other contexts
14+
creating new clusters or joining new nodes to an existing cluster.
15+
It was built to support [kubeadm](/docs/reference/setup-tools/kubeadm/), but can be used in other contexts
1616
for users that wish to start clusters without `kubeadm`. It is also built to
1717
work, via RBAC policy, with the
18-
[Kubelet TLS Bootstrapping](/docs/reference/access-authn-authz/kubelet-tls-bootstrapping/) system.
18+
[kubelet TLS Bootstrapping](/docs/reference/access-authn-authz/kubelet-tls-bootstrapping/) system.
1919

2020

2121
<!-- body -->
2222
## Bootstrap Tokens Overview
2323

2424
Bootstrap Tokens are defined with a specific type
2525
(`bootstrap.kubernetes.io/token`) of secrets that lives in the `kube-system`
26-
namespace. These Secrets are then read by the Bootstrap Authenticator in the
27-
API Server. Expired tokens are removed with the TokenCleaner controller in the
28-
Controller Manager. The tokens are also used to create a signature for a
26+
namespace. These Secrets are then read by the Bootstrap Authenticator in the
27+
API Server. Expired tokens are removed with the TokenCleaner controller in the
28+
Controller Manager. The tokens are also used to create a signature for a
2929
specific ConfigMap used in a "discovery" process through a BootstrapSigner
3030
controller.
3131

3232
## Token Format
3333

34-
Bootstrap Tokens take the form of `abcdef.0123456789abcdef`. More formally,
35-
they must match the regular expression `[a-z0-9]{6}\.[a-z0-9]{16}`.
34+
Bootstrap Tokens take the form of `abcdef.0123456789abcdef`.
35+
More formally, they must match the regular expression `[a-z0-9]{6}\.[a-z0-9]{16}`.
3636

3737
The first part of the token is the "Token ID" and is considered public
38-
information. It is used when referring to a token without leaking the secret
38+
information. It is used when referring to a token without leaking the secret
3939
part used for authentication. The second part is the "Token Secret" and should
4040
only be shared with trusted parties.
4141

@@ -56,8 +56,8 @@ Authorization: Bearer 07401b.f395accd246ae52d
5656
```
5757

5858
Tokens authenticate as the username `system:bootstrap:<token id>` and are members
59-
of the group `system:bootstrappers`. Additional groups may be specified in the
60-
token's Secret.
59+
of the group `system:bootstrappers`.
60+
Additional groups may be specified in the token's Secret.
6161

6262
Expired tokens can be deleted automatically by enabling the `tokencleaner`
6363
controller on the controller manager.
@@ -68,7 +68,7 @@ controller on the controller manager.
6868

6969
## Bootstrap Token Secret Format
7070

71-
Each valid token is backed by a secret in the `kube-system` namespace. You can
71+
Each valid token is backed by a secret in the `kube-system` namespace. You can
7272
find the full design doc
7373
[here](https://git.k8s.io/design-proposals-archive/cluster-lifecycle/bootstrap-discovery.md).
7474

@@ -104,20 +104,19 @@ stringData:
104104
```
105105
106106
The type of the secret must be `bootstrap.kubernetes.io/token` and the name must
107-
be `bootstrap-token-<token id>`. It must also exist in the `kube-system`
108-
namespace.
107+
be `bootstrap-token-<token id>`. It must also exist in the `kube-system` namespace.
109108

110-
The `usage-bootstrap-*` members indicate what this secret is intended to be used
111-
for. A value must be set to `true` to be enabled.
109+
The `usage-bootstrap-*` members indicate what this secret is intended to be used for.
110+
A value must be set to `true` to be enabled.
112111

113112
* `usage-bootstrap-authentication` indicates that the token can be used to
114113
authenticate to the API server as a bearer token.
115114
* `usage-bootstrap-signing` indicates that the token may be used to sign the
116115
`cluster-info` ConfigMap as described below.
117116

118-
The `expiration` field controls the expiry of the token. Expired tokens are
117+
The `expiration` field controls the expiry of the token. Expired tokens are
119118
rejected when used for authentication and ignored during ConfigMap signing.
120-
The expiry value is encoded as an absolute UTC time using RFC3339. Enable the
119+
The expiry value is encoded as an absolute UTC time using RFC3339. Enable the
121120
`tokencleaner` controller to automatically delete expired tokens.
122121

123122
## Token Management with kubeadm
@@ -127,9 +126,9 @@ You can use the `kubeadm` tool to manage tokens on a running cluster. See the
127126

128127
## ConfigMap Signing
129128

130-
In addition to authentication, the tokens can be used to sign a ConfigMap. This
131-
is used early in a cluster bootstrap process before the client trusts the API
132-
server. The signed ConfigMap can be authenticated by the shared token.
129+
In addition to authentication, the tokens can be used to sign a ConfigMap.
130+
This is used early in a cluster bootstrap process before the client trusts the API
131+
server. The signed ConfigMap can be authenticated by the shared token.
133132

134133
Enable ConfigMap signing by enabling the `bootstrapsigner` controller on the
135134
Controller Manager.
@@ -140,7 +139,7 @@ Controller Manager.
140139
141140
The ConfigMap that is signed is `cluster-info` in the `kube-public` namespace.
142141
The typical flow is that a client reads this ConfigMap while unauthenticated and
143-
ignoring TLS errors. It then validates the payload of the ConfigMap by looking
142+
ignoring TLS errors. It then validates the payload of the ConfigMap by looking
144143
at a signature embedded in the ConfigMap.
145144
146145
The ConfigMap may look like this:
@@ -168,15 +167,15 @@ data:
168167
```
169168

170169
The `kubeconfig` member of the ConfigMap is a config file with only the cluster
171-
information filled out. The key thing being communicated here is the
172-
`certificate-authority-data`. This may be expanded in the future.
170+
information filled out. The key thing being communicated here is the
171+
`certificate-authority-data`. This may be expanded in the future.
173172

174-
The signature is a JWS signature using the "detached" mode. To validate the
173+
The signature is a JWS signature using the "detached" mode. To validate the
175174
signature, the user should encode the `kubeconfig` payload according to JWS
176-
rules (base64 encoded while discarding any trailing `=`). That encoded payload
177-
is then used to form a whole JWS by inserting it between the 2 dots. You can
175+
rules (base64 encoded while discarding any trailing `=`). That encoded payload
176+
is then used to form a whole JWS by inserting it between the 2 dots. You can
178177
verify the JWS using the `HS256` scheme (HMAC-SHA256) with the full token (e.g.
179-
`07401b.f395accd246ae52d`) as the shared secret. Users _must_ verify that HS256
178+
`07401b.f395accd246ae52d`) as the shared secret. Users _must_ verify that HS256
180179
is used.
181180

182181
{{< warning >}}
@@ -188,4 +187,3 @@ client relying on the signature to bootstrap TLS trust.
188187

189188
Consult the [kubeadm implementation details](/docs/reference/setup-tools/kubeadm/implementation-details/)
190189
section for more information.
191-

content/en/docs/reference/access-authn-authz/certificate-signing-requests.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ the `spec.request` field. The CertificateSigningRequest denotes the signer (the
4646
recipient that the request is being made to) using the `spec.signerName` field.
4747
Note that `spec.signerName` is a required key after API version `certificates.k8s.io/v1`.
4848
In Kubernetes v1.22 and later, clients may optionally set the `spec.expirationSeconds`
49-
field to request a particular lifetime for the issued certificate. The minimum valid
49+
field to request a particular lifetime for the issued certificate. The minimum valid
5050
value for this field is `600`, i.e. ten minutes.
5151

5252
Once created, a CertificateSigningRequest must be approved before it can be signed.
@@ -113,13 +113,15 @@ signed, a security certificate.
113113

114114
Any signer that is made available for outside a particular cluster should provide information
115115
about how the signer works, so that consumers can understand what that means for CertifcateSigningRequests
116-
and (if enabled) [ClusterTrustBundles](#cluster-trust-bundles).
116+
and (if enabled) [ClusterTrustBundles](#cluster-trust-bundles).
117117
This includes:
118118

119119
1. **Trust distribution**: how trust anchors (CA certificates or certificate bundles) are distributed.
120120
1. **Permitted subjects**: any restrictions on and behavior when a disallowed subject is requested.
121-
1. **Permitted x509 extensions**: including IP subjectAltNames, DNS subjectAltNames, Email subjectAltNames, URI subjectAltNames etc, and behavior when a disallowed extension is requested.
122-
1. **Permitted key usages / extended key usages**: any restrictions on and behavior when usages different than the signer-determined usages are specified in the CSR.
121+
1. **Permitted x509 extensions**: including IP subjectAltNames, DNS subjectAltNames,
122+
Email subjectAltNames, URI subjectAltNames etc, and behavior when a disallowed extension is requested.
123+
1. **Permitted key usages / extended key usages**: any restrictions on and behavior
124+
when usages different than the signer-determined usages are specified in the CSR.
123125
1. **Expiration/certificate lifetime**: whether it is fixed by the signer, configurable by the admin, determined by the CSR `spec.expirationSeconds` field, etc
124126
and the behavior when the signer-determined expiration is different from the CSR `spec.expirationSeconds` field.
125127
1. **CA bit allowed/disallowed**: and behavior if a CSR contains a request a for a CA certificate when the signer does not permit it.
@@ -140,12 +142,12 @@ certificate expiration or lifetime. The expiration or lifetime therefore has to
140142
through the `spec.expirationSeconds` field of the CSR object. The built-in signers
141143
use the `ClusterSigningDuration` configuration option, which defaults to 1 year,
142144
(the `--cluster-signing-duration` command-line flag of the kube-controller-manager)
143-
as the default when no `spec.expirationSeconds` is specified. When `spec.expirationSeconds`
145+
as the default when no `spec.expirationSeconds` is specified. When `spec.expirationSeconds`
144146
is specified, the minimum of `spec.expirationSeconds` and `ClusterSigningDuration` is
145147
used.
146148

147149
{{< note >}}
148-
The `spec.expirationSeconds` field was added in Kubernetes v1.22. Earlier versions of Kubernetes do not honor this field.
150+
The `spec.expirationSeconds` field was added in Kubernetes v1.22. Earlier versions of Kubernetes do not honor this field.
149151
Kubernetes API servers prior to v1.22 will silently drop this field when the object is created.
150152
{{< /note >}}
151153

@@ -208,14 +210,14 @@ The kube-controller-manager implements [control plane signing](#signer-control-p
208210
signers. Failures for all of these are only reported in kube-controller-manager logs.
209211

210212
{{< note >}}
211-
The `spec.expirationSeconds` field was added in Kubernetes v1.22. Earlier versions of Kubernetes do not honor this field.
213+
The `spec.expirationSeconds` field was added in Kubernetes v1.22. Earlier versions of Kubernetes do not honor this field.
212214
Kubernetes API servers prior to v1.22 will silently drop this field when the object is created.
213215
{{< /note >}}
214216

215-
Distribution of trust happens out of band for these signers. Any trust outside of those described above are strictly
217+
Distribution of trust happens out of band for these signers. Any trust outside of those described above are strictly
216218
coincidental. For instance, some distributions may honor `kubernetes.io/legacy-unknown` as client certificates for the
217219
kube-apiserver, but this is not a standard.
218-
None of these usages are related to ServiceAccount token secrets `.data[ca.crt]` in any way. That CA bundle is only
220+
None of these usages are related to ServiceAccount token secrets `.data[ca.crt]` in any way. That CA bundle is only
219221
guaranteed to verify a connection to the API server using the default service (`kubernetes.default.svc`).
220222

221223
### Custom signers
@@ -240,7 +242,8 @@ were marked as approved.
240242
{{< /note >}}
241243

242244
{{< note >}}
243-
The `spec.expirationSeconds` field was added in Kubernetes v1.22. Earlier versions of Kubernetes do not honor this field.
245+
The `spec.expirationSeconds` field was added in Kubernetes v1.22.
246+
Earlier versions of Kubernetes do not honor this field.
244247
Kubernetes API servers prior to v1.22 will silently drop this field when the object is created.
245248
{{< /note >}}
246249

@@ -386,7 +389,7 @@ this API.
386389
{{< /note >}}
387390

388391
A ClusterTrustBundles is a cluster-scoped object for distributing X.509 trust
389-
anchors (root certificates) to workloads within the cluster. They're designed
392+
anchors (root certificates) to workloads within the cluster. They're designed
390393
to work well with the [signer](#signers) concept from CertificateSigningRequests.
391394

392395
ClusterTrustBundles can be used in two modes:
@@ -395,8 +398,8 @@ ClusterTrustBundles can be used in two modes:
395398
### Common properties and validation {#ctb-common}
396399

397400
All ClusterTrustBundle objects have strong validation on the contents of their
398-
`trustBundle` field. That field must contain one or more X.509 certificates,
399-
DER-serialized, each wrapped in a PEM `CERTIFICATE` block. The certificates
401+
`trustBundle` field. That field must contain one or more X.509 certificates,
402+
DER-serialized, each wrapped in a PEM `CERTIFICATE` block. The certificates
400403
must parse as valid X.509 certificates.
401404

402405
Esoteric PEM features like inter-block data and intra-block headers are either
@@ -444,8 +447,8 @@ controller in the cluster, so they have several security features:
444447
`<signerNameDomain>/<signerNamePath>` or match a pattern such as
445448
`<signerNameDomain>/*`.
446449
* Signer-linked ClusterTrustBundles **must** be named with a prefix derived from
447-
their `spec.signerName` field. Slashes (`/`) are replaced with colons (`:`),
448-
and a final colon is appended. This is followed by an arbitrary name. For
450+
their `spec.signerName` field. Slashes (`/`) are replaced with colons (`:`),
451+
and a final colon is appended. This is followed by an arbitrary name. For
449452
example, the signer `example.com/mysigner` can be linked to a
450453
ClusterTrustBundle `example.com:mysigner:<arbitrary-name>`.
451454

@@ -468,8 +471,8 @@ spec:
468471
trustBundle: "<... PEM data ...>"
469472
```
470473

471-
They are primarily intended for cluster configuration use cases. Each
472-
signer-unlinked ClusterTrustBundle is an independent object, in contrast to the
474+
They are primarily intended for cluster configuration use cases.
475+
Each signer-unlinked ClusterTrustBundle is an independent object, in contrast to the
473476
customary grouping behavior of signer-linked ClusterTrustBundles.
474477

475478
Signer-unlinked ClusterTrustBundles have no `attest` verb requirement.
@@ -483,7 +486,8 @@ signer-unlinked ClusterTrustBundles **must not** contain a colon (`:`).
483486

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

486-
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.
489+
The contents of ClusterTrustBundles can be injected into the container filesystem, similar to ConfigMaps and Secrets.
490+
See the [clusterTrustBundle projected volume source](/docs/concepts/storage/projected-volumes#clustertrustbundle) for more details.
487491

488492
<!-- TODO this should become a task page -->
489493
## How to issue a certificate for a user {#normal-user}
@@ -609,12 +613,13 @@ To test it, change the context to `myuser`:
609613
kubectl config use-context myuser
610614
```
611615

612-
613616
## {{% heading "whatsnext" %}}
614617

615618
* Read [Manage TLS Certificates in a Cluster](/docs/tasks/tls/managing-tls-in-a-cluster/)
616-
* View the source code for the kube-controller-manager built in [signer](https://github.com/kubernetes/kubernetes/blob/32ec6c212ec9415f604ffc1f4c1f29b782968ff1/pkg/controller/certificates/signer/cfssl_signer.go)
617-
* View the source code for the kube-controller-manager built in [approver](https://github.com/kubernetes/kubernetes/blob/32ec6c212ec9415f604ffc1f4c1f29b782968ff1/pkg/controller/certificates/approver/sarapprove.go)
619+
* View the source code for the kube-controller-manager built in
620+
[signer](https://github.com/kubernetes/kubernetes/blob/32ec6c212ec9415f604ffc1f4c1f29b782968ff1/pkg/controller/certificates/signer/cfssl_signer.go)
621+
* View the source code for the kube-controller-manager built in
622+
[approver](https://github.com/kubernetes/kubernetes/blob/32ec6c212ec9415f604ffc1f4c1f29b782968ff1/pkg/controller/certificates/approver/sarapprove.go)
618623
* For details of X.509 itself, refer to [RFC 5280](https://tools.ietf.org/html/rfc5280#section-3.1) section 3.1
619624
* For information on the syntax of PKCS#10 certificate signing requests, refer to [RFC 2986](https://tools.ietf.org/html/rfc2986)
620625
* Read about the ClusterTrustBundle API:

0 commit comments

Comments
 (0)