Skip to content

Commit 99fd007

Browse files
authored
Merge pull request #53216 from windsonsea/iceacc
[zh] Add text to service-accounts-admin.md
2 parents 18063a9 + 7e524cd commit 99fd007

File tree

1 file changed

+221
-11
lines changed

1 file changed

+221
-11
lines changed

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

Lines changed: 221 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,10 +1006,14 @@ time. Please refer to [auto-generated legacy ServiceAccount token clean up](#aut
10061006
<!--
10071007
## Delete/invalidate a ServiceAccount token {#delete-token}
10081008
1009+
### Delete/invalidate a long-lived/legacy ServiceAccount token {#delete-legacy-token}
1010+
10091011
If you know the name of the Secret that contains the token you want to remove:
10101012
-->
10111013
## 删除/废止 ServiceAccount 令牌 {#delete-token}
10121014
1015+
### 删除、废止长期存在的或遗留的 ServiceAccount 令牌 {#delete-legacy-token}
1016+
10131017
如果你知道 Secret 的名称且该 Secret 包含要移除的令牌:
10141018
10151019
```shell
@@ -1060,6 +1064,27 @@ Then, delete the Secret you now know the name of:
10601064
kubectl -n examplens delete secret/example-automated-thing-token-zyxwv
10611065
```
10621066

1067+
<!--
1068+
### Delete/invalidate a short-lived ServiceAccount token {#delete-short-lived}
1069+
1070+
Short lived ServiceAccount tokens automatically expire after the time-limit
1071+
specified during their creation. There is no central record of tokens issued,
1072+
so there is no way to revoke individual tokens.
1073+
1074+
If you have to revoke a short-lived token before its expiration, you
1075+
can delete and re-create the ServiceAccount it is associated to. This will
1076+
change its UID and hence invalidate **all** ServiceAccount tokens that were
1077+
created for it.
1078+
-->
1079+
### 删除、废止短期 ServiceAccount 令牌 {#delete-short-lived}
1080+
1081+
短期 ServiceAccount 令牌会在创建时指定的时限到期后自动失效。
1082+
由于没有集中记录已签发的令牌,所以无法单独撤销某个令牌。
1083+
1084+
如果你必须在时限到期前撤销某个令牌,你可以删除并重新创建与该令牌关联的 ServiceAccount。
1085+
这会更改此 ServiceAccount 的 UID,从而废止其创建的**所有** ServiceAccount 令牌。
1086+
1087+
10631088
<!--
10641089
## External ServiceAccount token signing and key management
10651090
-->
@@ -1073,24 +1098,18 @@ This feature enables kubernetes distributions to integrate with key management s
10731098
(for example, HSMs, cloud KMSes) for service account credential signing and verification.
10741099
To configure kube-apiserver to use external-jwt-signer set the `--service-account-signing-endpoint` flag
10751100
to the location of a Unix domain socket (UDS) on a filesystem, or be prefixed with an @ symbol and name
1076-
a UDS in the abstract socket namespace. At the configured UDS, shall be an RPC server which implements
1077-
[ExternalJWTSigner](https://github.com/kubernetes/kubernetes/blob/release-1.32/staging/src/k8s.io/externaljwt/apis/v1alpha1/api.proto).
1101+
a UDS in the abstract socket namespace. At the configured UDS shall be an RPC server which implements
1102+
an `ExternalJWTSigner` gRPC service.
1103+
10781104
The external-jwt-signer must be healthy and be ready to serve supported service account keys for the kube-apiserver to start.
10791105
-->
10801106
kube-apiserver 可以被配置为使用外部签名程序进行令牌签名和令牌验证密钥管理。
10811107
此特性允许各种 Kubernetes 发行版集成自己选择的密钥管理解决方案(例如 HSM、云上 KMS)来进行服务账户凭证签名和验证。
10821108
要配置 kube-apiserver 使用 external-jwt-signer,将 `--service-account-signing-endpoint`
10831109
标志设置为文件系统上 Unix 域套接字 (UDS) 所在的位置,或者以 @ 符号开头并在抽象套接字命名空间中命名 UDS。
1084-
在配置的 UDS 上,需要有一个实现
1085-
[ExternalJWTSigner](https://github.com/kubernetes/kubernetes/blob/release-1.32/staging/src/k8s.io/externaljwt/apis/v1alpha1/api.proto)
1086-
的 RPC 服务器。external-jwt-signer 必须处于健康状态,并准备好为 kube-apiserver 启动提供支持的服务账户密钥。
1110+
在配置的 UDS 上,需要有一个实现 `ExternalJWTSigner` gRPC 服务的 RPC 服务器。
10871111

1088-
<!--
1089-
Check out [KEP-740](https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/740-service-account-external-signing)
1090-
for more details on ExternalJWTSigner.
1091-
-->
1092-
有关 ExternalJWTSigner 的细节,查阅
1093-
[KEP-740](https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/740-service-account-external-signing)
1112+
external-jwt-signer 必须处于健康状态,并准备好为 kube-apiserver 启动提供支持的服务账户密钥。
10941113

10951114
{{< note >}}
10961115
<!--
@@ -1103,6 +1122,197 @@ kube-apiserver 的 `--service-account-key-file` 和 `--service-account-signing-k
11031122
它们在支持 JWT 签名和身份验证方面是互斥的。
11041123
{{< /note >}}
11051124

1125+
### Metadata
1126+
1127+
<!--
1128+
Metadata is meant to be called once by `kube-apiserver` on startup.
1129+
This enables the external signer to share metadata with kube-apiserver, like the max token lifetime that signer supports.
1130+
-->
1131+
Metadata 会在 kube-apiserver 启动时被调用一次。
1132+
Metadata 用于让外部签名器向 kube-apiserver 共享元数据,例如签名器所支持的最大令牌生命期。
1133+
1134+
<!--
1135+
```proto
1136+
rpc Metadata(MetadataRequest) returns (MetadataResponse) {}
1137+
1138+
message MetadataRequest {}
1139+
1140+
message MetadataResponse {
1141+
// used by kube-apiserver for defaulting/validation of JWT lifetime while accounting for configuration flag values:
1142+
// 1. `--service-account-max-token-expiration`
1143+
// 2. `--service-account-extend-token-expiration`
1144+
//
1145+
// * If `--service-account-max-token-expiration` is greater than `max_token_expiration_seconds`, kube-apiserver treats that as misconfiguration and exits.
1146+
// * If `--service-account-max-token-expiration` is not explicitly set, kube-apiserver defaults to `max_token_expiration_seconds`.
1147+
// * If `--service-account-extend-token-expiration` is true, the extended expiration is `min(1 year, max_token_expiration_seconds)`.
1148+
//
1149+
// `max_token_expiration_seconds` must be at least 600s.
1150+
int64 max_token_expiration_seconds = 1;
1151+
}
1152+
```
1153+
-->
1154+
```proto
1155+
rpc Metadata(MetadataRequest) returns (MetadataResponse) {}
1156+
1157+
message MetadataRequest {}
1158+
1159+
message MetadataResponse {
1160+
// kube-apiserver 基于这些配置参数值对 JWT 生命期执行以下默认处理和校验:
1161+
// 1. `--service-account-max-token-expiration`
1162+
// 2. `--service-account-extend-token-expiration`
1163+
//
1164+
// * 如果 `--service-account-max-token-expiration` 大于 `max_token_expiration_seconds`,kube-apiserver 会视为配置错误并退出。
1165+
// * 如果未显式设置 `--service-account-max-token-expiration`,kube-apiserver 默认采用 `max_token_expiration_seconds`。
1166+
// * 如果 `--service-account-extend-token-expiration` 为 true,则扩展后的过期时间为 `min(1 year, max_token_expiration_seconds)`。
1167+
//
1168+
// `max_token_expiration_seconds` 必须至少设为 600 秒。
1169+
int64 max_token_expiration_seconds = 1;
1170+
}
1171+
```
1172+
1173+
### FetchKeys
1174+
1175+
<!--
1176+
FetchKeys returns the set of public keys that are trusted to sign
1177+
Kubernetes service account tokens. Kube-apiserver will call this RPC:
1178+
* Every time it tries to validate a JWT from the service account issuer with an unknown key ID, and
1179+
* Periodically, so it can serve reasonably-up-to-date keys from the OIDC JWKs endpoint.
1180+
-->
1181+
FetchKeys 返回被信任用于签发 Kubernetes ServiceAccount 令牌的公钥集合。
1182+
kube-apiserver 会在以下情况下调用该 RPC:
1183+
1184+
* 每次验证服务账号发行者的 JWT 且其 key ID 未知时;
1185+
* 定期调用,以便 OIDC JWKs 端点能够提供较新的公钥。
1186+
1187+
<!--
1188+
```proto
1189+
rpc FetchKeys(FetchKeysRequest) returns (FetchKeysResponse) {}
1190+
1191+
message FetchKeysRequest {}
1192+
1193+
message FetchKeysResponse {
1194+
repeated Key keys = 1;
1195+
1196+
// The timestamp when this data was pulled from the authoritative source of
1197+
// truth for verification keys.
1198+
// kube-apiserver can export this from metrics, to enable end-to-end SLOs.
1199+
google.protobuf.Timestamp data_timestamp = 2;
1200+
1201+
// refresh interval for verification keys to pick changes if any.
1202+
// any value <= 0 is considered a misconfiguration.
1203+
int64 refresh_hint_seconds = 3;
1204+
}
1205+
1206+
message Key {
1207+
// A unique identifier for this key.
1208+
// Length must be <=1024.
1209+
string key_id = 1;
1210+
1211+
// The public key, PKIX-serialized.
1212+
// must be a public key supported by kube-apiserver (currently RSA 256 or ECDSA 256/384/521)
1213+
bytes key = 2;
1214+
1215+
// Set only for keys that are not used to sign bound tokens.
1216+
// eg: supported keys for legacy tokens.
1217+
// If set, key is used for verification but excluded from OIDC discovery docs.
1218+
// if set, external signer should not use this key to sign a JWT.
1219+
bool exclude_from_oidc_discovery = 3;
1220+
}
1221+
```
1222+
-->
1223+
```proto
1224+
rpc FetchKeys(FetchKeysRequest) returns (FetchKeysResponse) {}
1225+
1226+
message FetchKeysRequest {}
1227+
1228+
message FetchKeysResponse {
1229+
repeated Key keys = 1;
1230+
1231+
// 从公钥权威数据源获取此数据的时间戳。
1232+
// kube-apiserver 可通过指标导出此值,以启用端到端 SLO。
1233+
google.protobuf.Timestamp data_timestamp = 2;
1234+
1235+
// 公钥刷新间隔,用于检测是否存在变更。
1236+
// 任意 <= 0 的值都视为配置错误。
1237+
int64 refresh_hint_seconds = 3;
1238+
}
1239+
1240+
message Key {
1241+
// 公钥的唯一标识符。
1242+
// 长度必须 <= 1024。
1243+
string key_id = 1;
1244+
1245+
// PKIX 序列化的公钥。
1246+
// 必须是 kube-apiserver 支持的公钥类型(当前为 RSA 256 或 ECDSA 256/384/521)
1247+
bytes key = 2;
1248+
1249+
// 仅适用于不用于签发绑定令牌的密钥。
1250+
// 例如用于遗留令牌的兼容密钥。
1251+
// 若设置,则该密钥仅用于验证,且不会出现在 OIDC 发现文档中。
1252+
// 若设置,外部签名器不得使用该密钥签发 JWT。
1253+
bool exclude_from_oidc_discovery = 3;
1254+
}
1255+
```
1256+
1257+
### Sign
1258+
1259+
<!--
1260+
Sign takes a serialized JWT payload, and returns the serialized header and
1261+
signature. `kube-apiserver` then assembles the JWT from the header, payload,
1262+
and signature.
1263+
-->
1264+
Sign 接收已序列化的 JWT payload,并返回序列化后的 header 和 signature。
1265+
随后 kube-apiserver 将 header、payload 和 signature 组装成 JWT。
1266+
1267+
<!--
1268+
```proto
1269+
rpc Sign(SignJWTRequest) returns (SignJWTResponse) {}
1270+
1271+
message SignJWTRequest {
1272+
// URL-safe base64 wrapped payload to be signed.
1273+
// Exactly as it appears in the second segment of the JWT
1274+
string claims = 1;
1275+
}
1276+
1277+
message SignJWTResponse {
1278+
// header must contain only alg, kid, typ claims.
1279+
// typ must be “JWT”.
1280+
// kid must be non-empty, <=1024 characters, and its corresponding public key should not be excluded from OIDC discovery.
1281+
// alg must be one of the algorithms supported by kube-apiserver (currently RS256, ES256, ES384, ES512).
1282+
// header cannot have any additional data that kube-apiserver does not recognize.
1283+
// Already wrapped in URL-safe base64, exactly as it appears in the first segment of the JWT.
1284+
string header = 1;
1285+
1286+
// The signature for the JWT.
1287+
// Already wrapped in URL-safe base64, exactly as it appears in the final segment of the JWT.
1288+
string signature = 2;
1289+
}
1290+
```
1291+
-->
1292+
```proto
1293+
rpc Sign(SignJWTRequest) returns (SignJWTResponse) {}
1294+
1295+
message SignJWTRequest {
1296+
// 待签名的有效载荷,经 base64 编码的安全 URL,
1297+
// 与其在 JWT 第二段中的格式完全一致。
1298+
string claims = 1;
1299+
}
1300+
1301+
message SignJWTResponse {
1302+
// header 中只能包含 alg、kid、typ 字段。
1303+
// typ 必须为 "JWT"。
1304+
// kid 必须非空、长度 <=1024,并且其对应的公钥不能被排除在 OIDC 发现之外。
1305+
// alg 必须是 kube-apiserver 支持的算法(当前 RS256、ES256、ES384、ES512)。
1306+
// header 不得包含 kube-apiserver 无法识别的其他数据。
1307+
// 已经过 URL-safe base64 编码,与其在 JWT 第一部分中的形式完全一致。
1308+
string header = 1;
1309+
1310+
// JWT 的签名。
1311+
// 已经过 URL-safe base64 编码,与其在 JWT 最后一部分中的形式完全一致。
1312+
string signature = 2;
1313+
}
1314+
```
1315+
11061316
<!--
11071317
## Clean up
11081318

0 commit comments

Comments
 (0)