1
1
---
2
2
reviewers :
3
- - ericchiang
4
3
- mikedanese
5
- - jcbsmpsn
4
+ - liggitt
5
+ - smarterclayton
6
+ - awly
6
7
title : TLS bootstrapping
7
8
content_template : templates/concept
8
9
---
9
10
10
11
{{% capture overview %}}
11
12
12
13
This document describes how to set up TLS client certificate bootstrapping for
13
- kubelets. Kubernetes 1.4 introduced an API for requesting certificates from a
14
+ kubelets. Kubernetes 1.4 introduced an API for requesting certificates from a
14
15
cluster-level Certificate Authority (CA). The original intent of this API is to
15
16
enable provisioning of TLS client certificates for kubelets. The proposal can be
16
- found [ here] ( https://github.com/kubernetes/kubernetes/pull/20439 ) and progress
17
- on the feature is being tracked as [ feature #43 ] ( https://github.com/kubernetes/features/issues/43 ) .
17
+ found [ here] ( https://github.com/kubernetes/kubernetes/pull/20439 ) .
18
18
19
19
{{% /capture %}}
20
20
@@ -98,38 +98,24 @@ The kube-controller-manager flags are:
98
98
--cluster-signing-cert-file="/etc/path/to/kubernetes/ca/ca.crt" --cluster-signing-key-file="/etc/path/to/kubernetes/ca/ca.key"
99
99
```
100
100
101
- ### Approval controller
101
+ ### SubjectAccessReview Approval Controller
102
102
103
- In 1.7 the experimental "group auto approver" controller is dropped in favor of
104
- the new ` csrapproving ` controller that ships as part of
103
+ The ` csrapproving ` controller that ships as part of
105
104
[ kube-controller-manager] ( /docs/admin/kube-controller-manager/ ) and is enabled
106
- by default. The controller uses the [ ` SubjectAccessReview `
105
+ by default. The controller uses the [ ` SubjectAccessReview `
107
106
API] ( /docs/reference/access-authn-authz/authorization/#checking-api-access ) to
108
107
determine if a given user is authorized to request a CSR, then approves based on
109
108
the authorization outcome. To prevent conflicts with other approvers, the
110
- builtin approver doesn't explicitly deny CSRs, only ignoring unauthorized
109
+ builtin approver doesn't explicitly deny CSRs. It only ignores unauthorized
111
110
requests.
112
111
113
112
The controller categorizes CSRs into three subresources:
114
113
115
114
1 . ` nodeclient ` - a request by a user for a client certificate with ` O=system:nodes ` and ` CN=system:node:(node name) ` .
116
115
2 . ` selfnodeclient ` - a node renewing a client certificate with the same ` O ` and ` CN ` .
117
- 3 . ` selfnodeserver ` - a node renewing a serving certificate. (ALPHA, requires feature gate)
118
116
119
- The checks to determine if a CSR is a ` selfnodeserver ` request is currently tied
120
- to the kubelet's credential rotation implementation, an __ alpha__ feature. As
121
- such, the definition of ` selfnodeserver ` will likely change in a future and
122
- requires the ` RotateKubeletServerCertificate ` feature gate on the controller
123
- manager. The feature progress can be tracked at
124
- [ kubernetes/features #267 ] ( https://github.com/kubernetes/features/issues/267 ) .
125
-
126
- ```
127
- --feature-gates=RotateKubeletServerCertificate=true
128
- ```
129
-
130
- The following RBAC ` ClusterRoles ` represent the ` nodeclient ` , ` selfnodeclient ` ,
131
- and ` selfnodeserver ` capabilities. Similar roles may be automatically created in
132
- future releases.
117
+ The following RBAC ` ClusterRoles ` represent the ` nodeclient ` and
118
+ ` selfnodeclient ` , capabilities.
133
119
134
120
``` yml
135
121
# A ClusterRole which instructs the CSR approver to approve a user requesting
@@ -153,38 +139,21 @@ rules:
153
139
- apiGroups : ["certificates.k8s.io"]
154
140
resources : ["certificatesigningrequests/selfnodeclient"]
155
141
verbs : ["create"]
156
- ---
157
- # A ClusterRole which instructs the CSR approver to approve a node requesting a
158
- # serving cert matching its client cert.
159
- kind : ClusterRole
160
- apiVersion : rbac.authorization.k8s.io/v1
161
- metadata :
162
- name : approve-node-server-renewal-csr
163
- rules :
164
- - apiGroups : ["certificates.k8s.io"]
165
- resources : ["certificatesigningrequests/selfnodeserver"]
166
- verbs : ["create"]
167
142
` ` `
168
143
169
144
As of 1.8, equivalent roles to the ones listed above are automatically created
170
- as part of the default RBAC roles. For 1.8 clusters admins are recommended to
171
- bind tokens to the following roles instead of creating their own:
145
+ as part of the default RBAC roles. For 1.8 clusters admins are recommended to
146
+ bind node bootstrap identities to the following roles instead of creating their
147
+ own:
172
148
173
149
* ` system:certificates.k8s.io:certificatesigningrequests:nodeclient`
174
150
- Automatically approve CSRs for client certs bound to this role.
175
151
* `system:certificates.k8s.io:certificatesigningrequests:selfnodeclient`
176
152
- Automatically approve CSRs when a client bound to its role renews its own certificate.
177
153
178
- These powers can be granted to credentials, such as bootstrapping tokens. For
179
- example, to replicate the behavior provided by the removed auto-approval flag,
180
- of approving all CSRs by a single group :
181
-
182
- ` ` `
183
- # REMOVED: This flag no longer works as of 1.7.
184
- --insecure-experimental-approve-all-kubelet-csrs-for-group="system:bootstrappers"
185
- ` ` `
186
-
187
- An admin would create a `ClusterRoleBinding` targeting that group.
154
+ For example, to grant these permissions to identities attached to bootstrap
155
+ tokens, an admin would create a `ClusterRoleBinding` targeting the
156
+ `system:bootstrappers` group :
188
157
189
158
` ` ` yml
190
159
# Approve all CSRs for the group "system:bootstrappers"
@@ -203,7 +172,7 @@ roleRef:
203
172
` ` `
204
173
205
174
To let a node renew its own credentials, an admin can construct a
206
- `ClusterRoleBinding` targeting that node's credentials :
175
+ `ClusterRoleBinding` targeting that node's identity :
207
176
208
177
` ` ` yml
209
178
kind: ClusterRoleBinding
@@ -226,10 +195,13 @@ effectively removing it from the cluster once its certificate expires.
226
195
# # kubelet configuration
227
196
228
197
To request a client certificate from kube-apiserver, the kubelet first needs a
229
- path to a kubeconfig file that contains the bootstrap authentication token. You
230
- can use `kubectl config set-cluster`, `set-credentials`, and `set-context` to
231
- build this kubeconfig. Provide the name `kubelet-bootstrap` to `kubectl config
232
- set-credentials` and include `--token=<token-value>` as follows :
198
+ path to a kubeconfig file that contains the credentials for the identity that it
199
+ will use to bootstrap its individual node identity.
200
+
201
+ If you are using a bootstrap token, you can use `kubectl config set-cluster`,
202
+ ` set-credentials` , and `set-context` to build this kubeconfig. Provide the name
203
+ ` kubelet-bootstrap` to `kubectl config set-credentials` and include
204
+ `--token=<token-value>` as follows :
233
205
234
206
` ` `
235
207
kubectl config set-credentials kubelet-bootstrap --token=${BOOTSTRAP_TOKEN} --kubeconfig=bootstrap.kubeconfig
@@ -250,35 +222,46 @@ and key file will be placed in the directory specified by `--cert-dir`.
250
222
```
251
223
{{< /note >}}
252
224
253
- Additionally, in 1.7 the kubelet implements __alpha__ features for enabling
225
+ Additionally, in 1.7 the kubelet implements __beta__ features for enabling
254
226
rotation of both its client and/or serving certs. These can be enabled through
255
227
the respective `RotateKubeletClientCertificate` and
256
- `RotateKubeletServerCertificate` feature flags on the kubelet, but may change in
257
- backward incompatible ways in future releases.
228
+ `RotateKubeletServerCertificate` feature flags on the kubelet and are enabled by
229
+ default.
230
+
231
+ `RotateKubeletClientCertificate` causes the kubelet to rotate its client
232
+ certificates by creating new CSRs as its existing credentials expire. To enable
233
+ this feature pass the following flag to the kubelet:
258
234
259
235
```
260
- --feature-gates=RotateKubeletClientCertificate=true,RotateKubeletServerCertificate=true
236
+ --rotate-certificates
261
237
```
262
238
263
- `RotateKubeletClientCertificate` causes the kubelet to rotate its client
264
- certificates by creating new CSRs as its existing credentials expire.
265
239
`RotateKubeletServerCertificate` causes the kubelet to both request a serving
266
- certificate after bootstrapping its client credentials and rotate the
267
- certificate. The serving cert currently does not request DNS or IP SANs.
240
+ certificate after bootstrapping its client credentials and to rotate that
241
+ certificate. To enable this feature pass the following flag to the kubelet:
242
+
243
+ ```
244
+ --rotate-server-certificates
245
+ ```
246
+
247
+ {{< note >}}
248
+ **Note:** The CSR approving controllers implemented in core Kubernetes do not
249
+ approve node serving certificates for [security
250
+ reasons](https://github.com/kubernetes/community/pull/1982). To use
251
+ `RotateKubeletServerCertificate` operators need to run a custom approving
252
+ controller, or manually approve the serving certificate requests.
253
+ {{< /note >}}
268
254
269
255
## kubectl approval
270
256
271
257
The signing controller does not immediately sign all certificate requests.
272
258
Instead, it waits until they have been flagged with an "Approved" status by an
273
- appropriately-privileged user. This is intended to eventually be an automated
274
- process handled by an external approval controller, but for the alpha version of
275
- the API it can be done manually by a cluster administrator using kubectl. An
276
- administrator can list CSRs with `kubectl get csr` and describe one in detail
277
- with `kubectl describe csr <name>`. Before the 1.6 release there were [no direct
278
- approve/deny commands](https://github.com/kubernetes/kubernetes/issues/30163) so
279
- an approver had to update the Status field directly ([rough
280
- how-to](https://github.com/gtank/csrctl)). Later versions of Kubernetes offer
281
- `kubectl certificate approve <name>` and `kubectl certificate deny <name>`
282
- commands.
259
+ appropriately-privileged user. This flow is intended to allow for automated
260
+ approval handled by an external approval controller or the approval controller
261
+ implemented in the core controller-manager. However cluster administrators can
262
+ also manually approve certificate requests using kubectl. An administrator can
263
+ list CSRs with `kubectl get csr` and describe one in detail with `kubectl
264
+ describe csr <name>`. An administrator can approve or deny a CSR with `kubectl
265
+ certificate approve <name>` and `kubectl certificate deny <name>`.
283
266
284
267
{{% /capture %}}
0 commit comments