Skip to content

Commit 00d5266

Browse files
munnerzliggittdipesh-rawat
authored
Make KEP-4193 documentation updates (#45292)
* KEP-4193: beta documentation updates * Apply suggestions from code review Co-authored-by: Jordan Liggitt <[email protected]> * Apply suggestions from code review Co-authored-by: Dipesh Rawat <[email protected]> * include example JTI and node-name/uid output * Update service-accounts-admin.md Co-authored-by: Jordan Liggitt <[email protected]> --------- Co-authored-by: Jordan Liggitt <[email protected]> Co-authored-by: Dipesh Rawat <[email protected]>
1 parent 1acdc27 commit 00d5266

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed

content/en/docs/reference/access-authn-authz/service-accounts-admin.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,102 @@ for a number of reasons:
6060
without many constraints and have namespaced names, such configuration is
6161
usually portable.
6262

63+
## Bound service account tokens
64+
65+
ServiceAccount tokens can be bound to API objects that exist in the kube-apiserver.
66+
This can be used to tie the validity of a token to the existence of another API object.
67+
Supported object types are as follows:
68+
69+
* Pod (used for projected volume mounts, see below)
70+
* Secret (can be used to allow revoking a token by deleting the Secret)
71+
* Node (in v1.30, creating new node-bound tokens is alpha, using existing node-bound tokens is beta)
72+
73+
When a token is bound to an object, the object's `metadata.name` and `metadata.uid` are
74+
stored as extra 'private claims' in the issued JWT.
75+
76+
When a bound token is presented to the kube-apiserver, the service account authenticator
77+
will extract and verify these claims.
78+
If the referenced object no longer exists (or its `metadata.uid` does not match),
79+
the request will not be authenticated.
80+
81+
### Additional metadata in Pod bound tokens
82+
83+
{{< feature-state feature_gate_name="ServiceAccountTokenPodNodeInfo" >}}
84+
85+
When a service account token is bound to a Pod object, additional metadata is also
86+
embedded into the token that indicates the value of the bound pod's `spec.nodeName` field,
87+
and the uid of that Node, if available.
88+
89+
This node information is **not** verified by the kube-apiserver when the token is used for authentication.
90+
It is included so integrators do not have to fetch Pod or Node API objects to check the associated Node name
91+
and uid when inspecting a JWT.
92+
93+
### Verifying and inspecting private claims
94+
95+
The `TokenReview` API can be used to verify and extract private claims from a token:
96+
97+
1. First, assume you have a pod named `test-pod` and a service account named `my-sa`.
98+
2. Create a token that is bound to this Pod:
99+
100+
```shell
101+
kubectl create token my-sa --bound-object-kind="Pod" --bound-object-name="test-pod"
102+
```
103+
104+
3. Copy this token into a new file named `tokenreview.yaml`:
105+
106+
```yaml
107+
apiVersion: authentication.k8s.io/v1
108+
kind: TokenReview
109+
spec:
110+
token: <token from step 2>
111+
```
112+
113+
4. Submit this resource to the apiserver for review:
114+
115+
```shell
116+
kubectl create -o yaml -f tokenreview.yaml # we use '-o yaml' so we can inspect the output
117+
```
118+
119+
You should see an output like below:
120+
121+
```yaml
122+
apiVersion: authentication.k8s.io/v1
123+
kind: TokenReview
124+
metadata:
125+
creationTimestamp: null
126+
spec:
127+
token: <token>
128+
status:
129+
audiences:
130+
- https://kubernetes.default.svc.cluster.local
131+
authenticated: true
132+
user:
133+
extra:
134+
authentication.kubernetes.io/credential-id:
135+
- JTI=7ee52be0-9045-4653-aa5e-0da57b8dccdc
136+
authentication.kubernetes.io/node-name:
137+
- kind-control-plane
138+
authentication.kubernetes.io/node-uid:
139+
- 497e9d9a-47aa-4930-b0f6-9f2fb574c8c6
140+
authentication.kubernetes.io/pod-name:
141+
- test-pod
142+
authentication.kubernetes.io/pod-uid:
143+
- e87dbbd6-3d7e-45db-aafb-72b24627dff5
144+
groups:
145+
- system:serviceaccounts
146+
- system:serviceaccounts:default
147+
- system:authenticated
148+
uid: f8b4161b-2e2b-11e9-86b7-2afc33b31a7e
149+
username: system:serviceaccount:default:my-sa
150+
```
151+
152+
{{< note >}}
153+
Despite using `kubectl create -f` to create this resource, and defining it similar to
154+
other resource types in Kubernetes, TokenReview is a special type and the kube-apiserver
155+
does not actually persist the TokenReview object into etcd.
156+
Hence `kubectl get tokenreview` is not a valid command.
157+
{{< /note >}}
158+
63159
## Bound service account token volume mechanism {#bound-service-account-token-volume}
64160

65161
{{< feature-state feature_gate_name="BoundServiceAccountTokenVolume" >}}

content/en/docs/reference/command-line-tools-reference/feature-gates/service-account-token-jti.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ stages:
99
- stage: alpha
1010
defaultValue: false
1111
fromVersion: "1.29"
12+
toVersion: "1.29"
13+
- stage: beta
14+
defaultValue: true
15+
fromVersion: "1.30"
1216
---
1317
Controls whether JTIs (UUIDs) are embedded into generated service account tokens,
1418
and whether these JTIs are recorded into the Kubernetes audit log for future requests made by these tokens.

content/en/docs/reference/command-line-tools-reference/feature-gates/service-account-token-node-binding-validation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ stages:
99
- stage: alpha
1010
defaultValue: false
1111
fromVersion: "1.29"
12+
toVersion: "1.29"
13+
- stage: beta
14+
defaultValue: true
15+
fromVersion: "1.30"
1216
---
1317
Controls whether the apiserver will validate a Node reference in service account tokens.
1418

content/en/docs/reference/command-line-tools-reference/feature-gates/service-account-token-pod-node-info.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ stages:
99
- stage: alpha
1010
defaultValue: false
1111
fromVersion: "1.29"
12+
toVersion: "1.29"
13+
- stage: beta
14+
defaultValue: true
15+
fromVersion: "1.30"
1216
---
1317
Controls whether the apiserver embeds the node name and uid
1418
for the associated node when issuing service account tokens bound to Pod objects.

0 commit comments

Comments
 (0)