Skip to content

Commit 018e445

Browse files
authored
Merge pull request #28571 from mengjiao-liu/update-crt-sign
[zh] sync certificate-signing-requests
2 parents 8f27660 + af4a9c3 commit 018e445

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

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

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ state for some duration:
126126
<!--
127127
## Signers
128128
129-
All signers should provide information about how they work
129+
Custom signerNames can also be specified. All signers should provide information about how they work
130130
so that clients can predict what will happen to their CSRs.
131131
This includes:
132132
-->
133133
## 签名者 {#signers}
134134

135+
也可以指定自定义 signerName。
135136
所有签名者都应该提供自己工作方式的信息,
136137
以便客户端可以预期到他们的 CSR 将发生什么。
137138
此类信息包括:
@@ -423,8 +424,8 @@ O is the group that this user will belong to. You can refer to
423424
你可以参考 [RBAC](/zh/docs/reference/access-authn-authz/rbac/) 了解标准组的信息。
424425

425426
```shell
426-
openssl genrsa -out john.key 2048
427-
openssl req -new -key john.key -out john.csr
427+
openssl genrsa -out myuser.key 2048
428+
openssl req -new -key myuser.key -out myuser.csr
428429
```
429430

430431
<!--
@@ -443,7 +444,7 @@ cat <<EOF | kubectl apply -f -
443444
apiVersion: certificates.k8s.io/v1
444445
kind: CertificateSigningRequest
445446
metadata:
446-
name: john
447+
name: myuser
447448
spec:
448449
groups:
449450
- system:authenticated
@@ -459,13 +460,13 @@ Some points to note:
459460
460461
- `usages` has to be '`client auth`'
461462
- `request` is the base64 encoded value of the CSR file content.
462-
You can use this command to get that ```cat john.csr | base64 | tr -d "\n"```
463+
You can get the content using this command: ```cat myuser.csr | base64 | tr -d "\n"```
463464
-->
464465
需要注意的几点:
465466

466467
- `usage` 字段必须是 '`client auth`'
467468
- `request` 字段是 CSR 文件内容的 base64 编码值。
468-
要得到该值,可以执行命令 `cat john.csr | base64 | tr -d "\n"`
469+
要得到该值,可以执行命令 `cat myuser.csr | base64 | tr -d "\n"`
469470

470471
<!--
471472
### Approve certificate signing request
@@ -490,7 +491,7 @@ Approve the CSR:
490491
批准 CSR:
491492

492493
```shell
493-
kubectl certificate approve john
494+
kubectl certificate approve myuser
494495
```
495496

496497
<!--
@@ -503,14 +504,23 @@ Retrieve the certificate from the CSR.
503504
从 CSR 取得证书:
504505

505506
```shell
506-
kubectl get csr/john -o yaml
507+
kubectl get csr/myuser -o yaml
507508
```
508509

509510
<!--
510511
The Certificate value is in Base64-encoded format under `status.certificate`.
512+
513+
Export the issued certificate from the CertificateSigningRequest.
514+
511515
-->
512516
证书的内容使用 base64 编码,存放在字段 `status.certificate`
513517

518+
从 CertificateSigningRequest 导出颁发的证书。
519+
520+
```
521+
kubectl get csr myuser -o jsonpath='{.status.certificate}'| base64 -d > myuser.crt
522+
```
523+
514524
<!--
515525
### Create Role and Role Binding
516526
@@ -536,14 +546,13 @@ This is a sample command to create a RoleBinding for this new user:
536546
下面是为这个新用户创建 RoleBinding 的示例命令:
537547

538548
```shell
539-
kubectl create rolebinding developer-binding-john --role=developer --user=john
549+
kubectl create rolebinding developer-binding-myuser --role=developer --user=myuser
540550
```
541551

542552
<!--
543553
### Add to kubeconfig
544554
545555
The last step is to add this user into the kubeconfig file.
546-
We assume the key and crt files are located here "/home/vagrant/work/".
547556
548557
First, we need to add new credentials:
549558
-->
@@ -555,7 +564,7 @@ First, we need to add new credentials:
555564
首先,我们需要添加新的凭据:
556565

557566
```shell
558-
kubectl config set-credentials john --client-key=/home/vagrant/work/john.key --client-certificate=/home/vagrant/work/john.crt --embed-certs=true
567+
kubectl config set-credentials myuser --client-key=myuser.key --client-certificate=myuser.crt --embed-certs=true
559568

560569
```
561570

@@ -565,16 +574,16 @@ Then, you need to add the context:
565574
然后,你需要添加上下文:
566575

567576
```shell
568-
kubectl config set-context john --cluster=kubernetes --user=john
577+
kubectl config set-context myuser --cluster=kubernetes --user=myuser
569578
```
570579

571580
<!--
572-
To test it, change context to `john`
581+
To test it, change the context to `myuser`:
573582
-->
574-
来测试一下,把上下文切换为 `john`
583+
来测试一下,把上下文切换为 `myuser`
575584

576585
```shell
577-
kubectl config use-context john
586+
kubectl config use-context myuser
578587
```
579588

580589
<!--
@@ -684,12 +693,12 @@ status:
684693
<!--
685694
It's usual to set `status.conditions.reason` to a machine-friendly reason
686695
code using TitleCase; this is a convention but you can set it to anything
687-
you like. If you want to add a note just for human consumption, use the
696+
you like. If you want to add a note for human consumption, use the
688697
`status.conditions.message` field.
689698
-->
690699
`status.conditions.reason` 字段通常设置为一个首字母大写的对机器友好的原因码;
691700
这是一个命名约定,但你也可以随你的个人喜好设置。
692-
如果你想添加一个仅供人类使用的注释,那就用 `status.conditions.message` 字段。
701+
如果你想添加一个供人类使用的注释,那就用 `status.conditions.message` 字段。
693702

694703
<!--
695704
## Signing

0 commit comments

Comments
 (0)