Skip to content

Commit 92a09b2

Browse files
committed
Style tweaking for CSR reference page
1 parent e028d3d commit 92a09b2

File tree

1 file changed

+99
-70
lines changed

1 file changed

+99
-70
lines changed

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

Lines changed: 99 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@ A CertificateSigningRequest (CSR) resource is used to request that a certificate
2121
by a denoted signer, after which the request may be approved or denied before
2222
finally being signed.
2323

24-
25-
2624
<!-- body -->
25+
2726
## Request signing process
2827

29-
The _CertificateSigningRequest_ resource type allows a client to ask for an X.509 certificate
28+
The CertificateSigningRequest resource type allows a client to ask for an X.509 certificate
3029
be issued, based on a signing request.
3130
The CertificateSigningRequest object includes a PEM-encoded PKCS#10 signing request in
32-
the `spec.request` field. The CertificateSigningRequest denotes the _signer_ (the
31+
the `spec.request` field. The CertificateSigningRequest denotes the signer (the
3332
recipient that the request is being made to) using the `spec.signerName` field.
34-
Note that `spec.signerName` is a required key after api version `certificates.k8s.io/v1`.
33+
Note that `spec.signerName` is a required key after API version `certificates.k8s.io/v1`.
3534

3635
Once created, a CertificateSigningRequest must be approved before it can be signed.
3736
Depending on the signer selected, a CertificateSigningRequest may be automatically approved
@@ -68,54 +67,69 @@ This includes:
6867
1. **Permitted subjects**: any restrictions on and behavior when a disallowed subject is requested.
6968
1. **Permitted x509 extensions**: including IP subjectAltNames, DNS subjectAltNames, Email subjectAltNames, URI subjectAltNames etc, and behavior when a disallowed extension is requested.
7069
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.
71-
1. **Expiration/certificate lifetime**: whether it is fixed by the signer, configurable by the admin, determined by the CSR object etc and the behavior when an expiration is different than the signer-determined expiration that is specified in the CSR.
70+
1. **Expiration/certificate lifetime**: whether it is fixed by the signer, configurable by the admin, determined by the CSR object etc
71+
and the behavior when an expiration is different than the signer-determined expiration that is specified in the CSR.
7272
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.
7373

74-
Commonly, the `status.certificate` field contains a single PEM-encoded X.509 certificate once the CSR is approved and the certificate is issued. Some signers store multiple certificates into the `status.certificate` field. In that case, the documentation for the signer should specify the meaning of additional certificates; for example, this might be the certificate plus intermediates to be presented during TLS handshakes.
74+
Commonly, the `status.certificate` field contains a single PEM-encoded X.509
75+
certificate once the CSR is approved and the certificate is issued. Some
76+
signers store multiple certificates into the `status.certificate` field. In
77+
that case, the documentation for the signer should specify the meaning of
78+
additional certificates; for example, this might be the certificate plus
79+
intermediates to be presented during TLS handshakes.
7580

7681
### Kubernetes signers
7782

7883
Kubernetes provides built-in signers that each have a well-known `signerName`:
7984

80-
1. `kubernetes.io/kube-apiserver-client`: signs certificates that will be honored as client-certs by the kube-apiserver.
81-
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
82-
1. Trust distribution: signed certificates must be honored as client-certificates by the kube-apiserver. The CA bundle is not distributed by any other means.
83-
1. Permitted subjects - no subject restrictions, but approvers and signers may choose not to approve or sign. Certain subjects like cluster-admin level users or groups vary between distributions and installations, but deserve additional scrutiny before approval and signing. The `CertificateSubjectRestriction` admission plugin is available and enabled by default to restrict `system:masters`, but it is often not the only cluster-admin subject in a cluster.
85+
1. `kubernetes.io/kube-apiserver-client`: signs certificates that will be honored as client certificates by the API server.
86+
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
87+
1. Trust distribution: signed certificates must be honored as client certificates by the API server. The CA bundle is not distributed by any other means.
88+
1. Permitted subjects - no subject restrictions, but approvers and signers may choose not to approve or sign.
89+
Certain subjects like cluster-admin level users or groups vary between distributions and installations,
90+
but deserve additional scrutiny before approval and signing.
91+
The `CertificateSubjectRestriction` admission plugin is enabled by default to restrict `system:masters`,
92+
but it is often not the only cluster-admin subject in a cluster.
8493
1. Permitted x509 extensions - honors subjectAltName and key usage extensions and discards other extensions.
85-
1. Permitted key usages - must include []string{"client auth"}. Must not include key usages beyond []string{"digital signature", "key encipherment", "client auth"}
86-
1. Expiration/certificate lifetime - minimum of CSR signer or request. The signer is responsible for checking that the certificate lifetime is valid and permissible.
94+
1. Permitted key usages - must include `["client auth"]`. Must not include key usages beyond `["digital signature", "key encipherment", "client auth"]`.
95+
1. Expiration/certificate lifetime - minimum of CSR signer or request.
96+
The signer is responsible for checking that the certificate lifetime is valid and permissible.
8797
1. CA bit allowed/disallowed - not allowed.
8898

89-
1. `kubernetes.io/kube-apiserver-client-kubelet`: signs client certificates that will be honored as client-certs by the
90-
kube-apiserver.
91-
May be auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
92-
1. Trust distribution: signed certificates must be honored as client-certificates by the kube-apiserver. The CA bundle
99+
1. `kubernetes.io/kube-apiserver-client-kubelet`: signs client certificates that will be honored as client certificates by the
100+
API server.
101+
May be auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
102+
1. Trust distribution: signed certificates must be honored as client certificates by the API server. The CA bundle
93103
is not distributed by any other means.
94-
1. Permitted subjects - organizations are exactly `[]string{"system:nodes"}`, common name starts with `"system:node:"`
104+
1. Permitted subjects - organizations are exactly `["system:nodes"]`, common name starts with "`system:node:`".
95105
1. Permitted x509 extensions - honors key usage extensions, forbids subjectAltName extensions and drops other extensions.
96-
1. Permitted key usages - exactly `[]string{"key encipherment", "digital signature", "client auth"}`
97-
1. Expiration/certificate lifetime - minimum of CSR signer or request. The signer is responsible for checking that the certificate lifetime is valid and permissible.
106+
1. Permitted key usages - exactly `["key encipherment", "digital signature", "client auth"]`.
107+
1. Expiration/certificate lifetime - minimum of CSR signer or request.
108+
The signer is responsible for checking that the certificate lifetime is valid and permissible.
98109
1. CA bit allowed/disallowed - not allowed.
99110

100111
1. `kubernetes.io/kubelet-serving`: signs serving certificates that are honored as a valid kubelet serving certificate
101-
by the kube-apiserver, but has no other guarantees.
102-
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
103-
1. Trust distribution: signed certificates must be honored by the kube-apiserver as valid to terminate connections to a kubelet. The CA bundle is not distributed by any other means.
104-
1. Permitted subjects - organizations are exactly `[]string{"system:nodes"}`, common name starts with `"system:node:"`
105-
1. Permitted x509 extensions - honors key usage and DNSName/IPAddress subjectAltName extensions, forbids EmailAddress and URI subjectAltName extensions, drops other extensions. At least one DNS or IP subjectAltName must be present.
106-
1. Permitted key usages - exactly `[]string{"key encipherment", "digital signature", "server auth"}`
112+
by the API server, but has no other guarantees.
113+
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
114+
1. Trust distribution: signed certificates must be honored by the API server as valid to terminate connections to a kubelet.
115+
The CA bundle is not distributed by any other means.
116+
1. Permitted subjects - organizations are exactly `["system:nodes"]`, common name starts with "`system:node:`".
117+
1. Permitted x509 extensions - honors key usage and DNSName/IPAddress subjectAltName extensions, forbids EmailAddress and
118+
URI subjectAltName extensions, drops other extensions. At least one DNS or IP subjectAltName must be present.
119+
1. Permitted key usages - exactly `["key encipherment", "digital signature", "server auth"]`.
107120
1. Expiration/certificate lifetime - minimum of CSR signer or request.
108121
1. CA bit allowed/disallowed - not allowed.
109122

110123
1. `kubernetes.io/legacy-unknown`: has no guarantees for trust at all. Some third-party distributions of Kubernetes
111-
may honor client certificates signed by it. The stable CertificateSigningRequest API (version `certificates.k8s.io/v1` and later)
112-
does not allow to set the `signerName` as `kubernetes.io/legacy-unknown`.
113-
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
114-
1. Trust distribution: None. There is no standard trust or distribution for this signer in a Kubernetes cluster.
124+
may honor client certificates signed by it. The stable CertificateSigningRequest API (version `certificates.k8s.io/v1` and later)
125+
does not allow to set the `signerName` as `kubernetes.io/legacy-unknown`.
126+
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
127+
1. Trust distribution: None. There is no standard trust or distribution for this signer in a Kubernetes cluster.
115128
1. Permitted subjects - any
116129
1. Permitted x509 extensions - honors subjectAltName and key usage extensions and discards other extensions.
117130
1. Permitted key usages - any
118-
1. Expiration/certificate lifetime - minimum of CSR signer or request. The signer is responsible for checking that the certificate lifetime is valid and permissible.
131+
1. Expiration/certificate lifetime - minimum of CSR signer or request.
132+
The signer is responsible for checking that the certificate lifetime is valid and permissible.
119133
1. CA bit allowed/disallowed - not allowed.
120134

121135
{{< note >}}
@@ -126,7 +140,7 @@ Distribution of trust happens out of band for these signers. Any trust outside
126140
coincidental. For instance, some distributions may honor `kubernetes.io/legacy-unknown` as client certificates for the
127141
kube-apiserver, but this is not a standard.
128142
None of these usages are related to ServiceAccount token secrets `.data[ca.crt]` in any way. That CA bundle is only
129-
guaranteed to verify a connection to the kube-apiserver using the default service (`kubernetes.default.svc`).
143+
guaranteed to verify a connection to the API server using the default service (`kubernetes.default.svc`).
130144

131145
## Authorization
132146

@@ -156,24 +170,30 @@ To allow signing a CertificateSigningRequest:
156170

157171
{{< codenew file="access/certificate-signing-request/clusterrole-sign.yaml" >}}
158172

159-
## Normal User
173+
## Normal user
160174

161-
A few steps are required in order to get normal user to be able to authenticate and invoke an API. First, this user must have certificate issued by the Kubernetes Cluster, and then present that Certificate to the API call as the Certificate Header or through the kubectl.
175+
A few steps are required in order to get a normal user to be able to
176+
authenticate and invoke an API. First, this user must have certificate issued
177+
by the Kubernetes cluster, and then present that Certificate to the API call
178+
as the Certificate Header or through the kubectl.
162179

163-
### Create Private Key
180+
### Create private key
164181

165-
The following scripts show how to generate PKI private key and CSR. It is important to set CN and O attribute of the CSR. CN is the name of the user and O is the group that this user will belong to. You can refer to [RBAC](/docs/reference/access-authn-authz/rbac/) for standard groups.
182+
The following scripts show how to generate PKI private key and CSR. It is
183+
important to set CN and O attribute of the CSR. CN is the name of the user and
184+
O is the group that this user will belong to. You can refer to
185+
[RBAC](/docs/reference/access-authn-authz/rbac/) for standard groups.
166186

167-
```
187+
```shell
168188
openssl genrsa -out john.key 2048
169189
openssl req -new -key john.key -out john.csr
170190
```
171191

172-
### Create Certificate Request Kubernetes Object
192+
### Create CertificateSigningRequest
173193

174194
Create a CertificateSigningRequest and submit it to a Kubernetes Cluster via kubectl. Below is a script to generate the CertificateSigningRequest.
175195

176-
```
196+
```shell
177197
cat <<EOF | kubectl apply -f -
178198
apiVersion: certificates.k8s.io/v1
179199
kind: CertificateSigningRequest
@@ -191,68 +211,78 @@ EOF
191211

192212
Some points to note:
193213

194-
- usage has to be 'client auth'
195-
- request is the base64 encoded value of the CSR file content. You can use this command to get that ```cat john.csr | base64 | tr -d "\n"```
214+
- `usages` has to be '`client auth`'
215+
- `request` is the base64 encoded value of the CSR file content.
216+
You can get the content using this command: ```cat john.csr | base64 | tr -d "\n"```
196217

197-
### Approve Certificate Request
218+
### Approve certificate signing request
198219

199220
Use kubectl to create a CSR and approve it.
200221

201-
Get the list of CSRs
202-
```
222+
Get the list of CSRs:
223+
224+
```shell
203225
kubectl get csr
204226
```
205227

206-
Approve the CSR
207-
```
228+
Approve the CSR:
229+
230+
```shell
208231
kubectl certificate approve john
209232
```
210233

211-
### Get the Certificate
234+
### Get the certificate
212235

213-
Retrieve the Certificate from the CSR.
236+
Retrieve the certificate from the CSR:
214237

215-
```
238+
```shell
216239
kubectl get csr/john -o yaml
217240
```
218241

219-
The Certificate value is in Base64-encoded format under status.certificate.
242+
The certificate value is in Base64-encoded format under `status.certificate`.
220243

221-
### Create Role and Role Binding
244+
### Create Role and RoleBinding
222245

223-
You get the Certificate already. Now it is time to define the Role and Role Binding for this user to access Kubernetes Cluster resources.
246+
With the certificate created. it is time to define the Role and RoleBinding for
247+
this user to access Kubernetes cluster resources.
224248

225-
This is a sample script to create role for this new user
226-
```
249+
This is a sample script to create a Role for this new user:
250+
251+
```shell
227252
kubectl create role developer --verb=create --verb=get --verb=list --verb=update --verb=delete --resource=pods
228253
```
229254

230-
This is a sample script to create role binding for this new user
231-
```
255+
This is a sample command to create a RoleBinding for this new user:
256+
257+
```shell
232258
kubectl create rolebinding developer-binding-john --role=developer --user=john
233259
```
234260

235-
### Add to KubeConfig
261+
### Add to kubeconfig
262+
263+
The last step is to add this user into the kubeconfig file.
264+
This example assumes the key and certificate files are located at "/home/vagrant/work/".
236265

237-
The last step is to add this user into the KubeConfig. We assume the key and crt files are located here "/home/vagrant/work/".
266+
First, you need to add new credentials:
238267

239-
First, we need to add new credentials
240268
```
241269
kubectl config set-credentials john --client-key=/home/vagrant/work/john.key --client-certificate=/home/vagrant/work/john.crt --embed-certs=true
242270
243271
```
244272

245-
Then, we need to add the context
273+
Then, you need to add the context:
274+
246275
```
247276
kubectl config set-context john --cluster=kubernetes --user=john
248277
```
249278

250-
To test it, change kubecontext to john
279+
To test it, change the context to `john`:
280+
251281
```
252282
kubectl config use-context john
253283
```
254284

255-
## Approval & rejection
285+
## Approval or rejection {#approval-rejection}
256286

257287
### Control plane automated approval {#approval-rejection-control-plane}
258288

@@ -262,25 +292,25 @@ permissions on CSRs for node credentials to authorization.
262292
The kube-controller-manager POSTs SubjectAccessReview resources to the API server
263293
in order to check authorization for certificate approval.
264294

265-
### Approval & rejection using `kubectl` {#approval-rejection-kubectl}
295+
### Approval or rejection using `kubectl` {#approval-rejection-kubectl}
266296

267297
A Kubernetes administrator (with appropriate permissions) can manually approve
268298
(or deny) CertificateSigningRequests by using the `kubectl certificate
269299
approve` and `kubectl certificate deny` commands.
270300

271301
To approve a CSR with kubectl:
272302

273-
```bash
303+
```shell
274304
kubectl certificate approve <certificate-signing-request-name>
275305
```
276306

277307
Likewise, to deny a CSR:
278308

279-
```bash
309+
```shell
280310
kubectl certificate deny <certificate-signing-request-name>
281311
```
282312

283-
### Approval & rejection using the Kubernetes API {#approval-rejection-api-client}
313+
### Approval or rejection using the Kubernetes API {#approval-rejection-api-client}
284314

285315
Users of the REST API can approve CSRs by submitting an UPDATE request to the `approval`
286316
subresource of the CSR to be approved. For example, you could write an
@@ -329,7 +359,8 @@ you like. If you want to add a note just for human consumption, use the
329359

330360
### Control plane signer {#signer-control-plane}
331361

332-
The Kubernetes control plane implements each of the [Kubernetes signers](/docs/reference/access-authn-authz/certificate-signing-requests/#kubernetes-signers),
362+
The Kubernetes control plane implements each of the
363+
[Kubernetes signers](/docs/reference/access-authn-authz/certificate-signing-requests/#kubernetes-signers),
333364
as part of the kube-controller-manager.
334365

335366
{{< note >}}
@@ -389,13 +420,11 @@ status:
389420
certificate: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JS..."
390421
```
391422

392-
393-
394423
## {{% heading "whatsnext" %}}
395424

396-
397425
* Read [Manage TLS Certificates in a Cluster](/docs/tasks/tls/managing-tls-in-a-cluster/)
398426
* 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)
399427
* 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)
400428
* For details of X.509 itself, refer to [RFC 5280](https://tools.ietf.org/html/rfc5280#section-3.1) section 3.1
401429
* For information on the syntax of PKCS#10 certificate signing requests, refer to [RFC 2986](https://tools.ietf.org/html/rfc2986)
430+

0 commit comments

Comments
 (0)