@@ -38,26 +38,26 @@ manually through `easyrsa`, `openssl` or `cfssl`.
38
38
cd easy-rsa-master/easyrsa3
39
39
./easyrsa init-pki
40
40
41
- <!--
42
- 1 . Generate a new certificate authority (CA). `--batch` sets automatic mode;
43
- `--req-cn` specifies the Common Name (CN) for the CA's new root certificate.
44
- -->
45
- 1 . 生成新的证书颁发机构(CA)。参数 ` --batch ` 用于设置自动模式;
41
+ <!--
42
+ 2 . Generate a new certificate authority (CA). `--batch` sets automatic mode;
43
+ `--req-cn` specifies the Common Name (CN) for the CA's new root certificate.
44
+ -->
45
+ 2 . 生成新的证书颁发机构(CA)。参数 ` --batch ` 用于设置自动模式;
46
46
参数 ` --req-cn ` 用于设置新的根证书的通用名称(CN)。
47
47
48
48
./easyrsa --batch "--req-cn=${MASTER_IP}@`date +%s`" build-ca nopass
49
49
50
- <!--
51
- 1 . Generate server certificate and key.
52
- The argument `--subject-alt-name` sets the possible IPs and DNS names the API server will
53
- be accessed with. The `MASTER_CLUSTER_IP` is usually the first IP from the service CIDR
54
- that is specified as the `--service-cluster-ip-range` argument for both the API server and
55
- the controller manager component. The argument `--days` is used to set the number of days
56
- after which the certificate expires.
57
- The sample below also assumes that you are using `cluster.local` as the default
58
- DNS domain name.
59
- -->
60
- 1 . 生成服务器证书和秘钥。
50
+ <!--
51
+ 3 . Generate server certificate and key.
52
+ The argument `--subject-alt-name` sets the possible IPs and DNS names the API server will
53
+ be accessed with. The `MASTER_CLUSTER_IP` is usually the first IP from the service CIDR
54
+ that is specified as the `--service-cluster-ip-range` argument for both the API server and
55
+ the controller manager component. The argument `--days` is used to set the number of days
56
+ after which the certificate expires.
57
+ The sample below also assumes that you are using `cluster.local` as the default
58
+ DNS domain name.
59
+ -->
60
+ 3 . 生成服务器证书和秘钥。
61
61
参数 ` --subject-alt-name ` 设置 API 服务器的 IP 和 DNS 名称。
62
62
` MASTER_CLUSTER_IP ` 用于 API 服务器和控制管理器,通常取 CIDR 的第一个 IP,由 ` --service-cluster-ip-range ` 的参数提供。
63
63
参数 ` --days ` 用于设置证书的过期时间。
@@ -73,12 +73,15 @@ manually through `easyrsa`, `openssl` or `cfssl`.
73
73
--days=10000 \
74
74
build-server-full server nopass
75
75
76
- <!--
77
- 1. Copy `pki/ca.crt`, `pki/issued/server.crt`, and `pki/private/server.key` to your directory.
78
- 1. Fill in and add the following parameters into the API server start parameters:
79
- -->
80
- 1 . 拷贝文件 ` pki/ca.crt ` 、` pki/issued/server.crt ` 和 ` pki/private/server.key ` 到你的目录中。
81
- 1 . 在 API 服务器的启动参数中添加以下参数:
76
+ <!--
77
+ 4. Copy `pki/ca.crt`, `pki/issued/server.crt`, and `pki/private/server.key` to your directory.
78
+ -->
79
+ 4 . 拷贝文件 ` pki/ca.crt ` 、` pki/issued/server.crt ` 和 ` pki/private/server.key ` 到你的目录中。
80
+
81
+ <!--
82
+ 5. Fill in and add the following parameters into the API server start parameters:
83
+ -->
84
+ 5 . 在 API 服务器的启动参数中添加以下参数:
82
85
83
86
--client-ca-file=/yourdirectory/ca.crt
84
87
--tls-cert-file=/yourdirectory/server.crt
@@ -98,30 +101,30 @@ manually through `easyrsa`, `openssl` or `cfssl`.
98
101
99
102
openssl genrsa -out ca.key 2048
100
103
101
- <!--
102
- 1 . According to the ca.key generate a ca.crt (use -days to set the certificate effective time):
103
- -->
104
- 1 . 在 ca.key 文件的基础上,生成 ca.crt 文件(用参数 -days 设置证书有效期)
104
+ <!--
105
+ 2 . According to the ca.key generate a ca.crt (use -days to set the certificate effective time):
106
+ -->
107
+ 2 . 在 ca.key 文件的基础上,生成 ca.crt 文件(用参数 -days 设置证书有效期)
105
108
106
109
openssl req -x509 -new -nodes -key ca.key -subj "/CN=${MASTER_IP}" -days 10000 -out ca.crt
107
110
108
- <!--
109
- 1 . Generate a server.key with 2048bit:
110
- -->
111
- 1 . 生成一个 2048 位的 server.key 文件:
111
+ <!--
112
+ 3 . Generate a server.key with 2048bit:
113
+ -->
114
+ 3 . 生成一个 2048 位的 server.key 文件:
112
115
113
116
openssl genrsa -out server.key 2048
114
117
115
- <!--
116
- 1 . Create a config file for generating a Certificate Signing Request (CSR).
117
- Be sure to substitute the values marked with angle brackets (e.g. `<MASTER_IP>`)
118
- with real values before saving this to a file (e.g. `csr.conf`).
119
- Note that the value for `MASTER_CLUSTER_IP` is the service cluster IP for the
120
- API server as described in previous subsection.
121
- The sample below also assumes that you are using `cluster.local` as the default
122
- DNS domain name.
123
- -->
124
- 1 . 创建一个用于生成证书签名请求(CSR)的配置文件。
118
+ <!--
119
+ 4 . Create a config file for generating a Certificate Signing Request (CSR).
120
+ Be sure to substitute the values marked with angle brackets (e.g. `<MASTER_IP>`)
121
+ with real values before saving this to a file (e.g. `csr.conf`).
122
+ Note that the value for `MASTER_CLUSTER_IP` is the service cluster IP for the
123
+ API server as described in previous subsection.
124
+ The sample below also assumes that you are using `cluster.local` as the default
125
+ DNS domain name.
126
+ -->
127
+ 4 . 创建一个用于生成证书签名请求(CSR)的配置文件。
125
128
保存文件(例如:` csr.conf ` )前,记得用真实值替换掉尖括号中的值(例如:` <MASTER_IP> ` )。
126
129
注意:` MASTER_CLUSTER_IP ` 就像前一小节所述,它的值是 API 服务器的服务集群 IP。
127
130
下面的例子假定你的默认 DNS 域名为 ` cluster.local ` 。
@@ -160,33 +163,33 @@ manually through `easyrsa`, `openssl` or `cfssl`.
160
163
extendedKeyUsage=serverAuth,clientAuth
161
164
subjectAltName=@alt_names
162
165
163
- <!--
164
- 1 . Generate the certificate signing request based on the config file:
165
- -->
166
- 1 . 基于上面的配置文件生成证书签名请求:
166
+ <!--
167
+ 5 . Generate the certificate signing request based on the config file:
168
+ -->
169
+ 5 . 基于上面的配置文件生成证书签名请求:
167
170
168
171
openssl req -new -key server.key -out server.csr -config csr.conf
169
172
170
- <!--
171
- 1 . Generate the server certificate using the ca.key, ca.crt and server.csr:
172
- -->
173
- 1 . 基于 ca.key、ca.crt 和 server.csr 等三个文件生成服务端证书:
173
+ <!--
174
+ 6 . Generate the server certificate using the ca.key, ca.crt and server.csr:
175
+ -->
176
+ 6 . 基于 ca.key、ca.crt 和 server.csr 等三个文件生成服务端证书:
174
177
175
178
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key \
176
179
-CAcreateserial -out server.crt -days 10000 \
177
180
-extensions v3_ext -extfile csr.conf
178
181
179
- <!--
180
- 1 . View the certificate signing request:
181
- -->
182
- 1 . 查看证书签名请求:
182
+ <!--
183
+ 7 . View the certificate signing request:
184
+ -->
185
+ 7 . 查看证书签名请求:
183
186
184
187
openssl req -noout -text -in ./server.csr
185
188
186
- <!--
187
- 1 . View the certificate:
188
- -->
189
- 1 . 查看证书:
189
+ <!--
190
+ 8 . View the certificate:
191
+ -->
192
+ 8 . 查看证书:
190
193
191
194
openssl x509 -noout -text -in ./server.crt
192
195
@@ -217,20 +220,20 @@ Finally, add the same parameters into the API server start parameters.
217
220
curl -L https://github.com/cloudflare/cfssl/releases/download/v1.5.0/cfssl-certinfo_1.5.0_linux_amd64 -o cfssl-certinfo
218
221
chmod +x cfssl-certinfo
219
222
220
- <!--
221
- 1 . Create a directory to hold the artifacts and initialize cfssl:
222
- -->
223
- 1 . 创建一个目录,用它保存所生成的构件和初始化 cfssl:
223
+ <!--
224
+ 2 . Create a directory to hold the artifacts and initialize cfssl:
225
+ -->
226
+ 2 . 创建一个目录,用它保存所生成的构件和初始化 cfssl:
224
227
225
228
mkdir cert
226
229
cd cert
227
230
../cfssl print-defaults config > config.json
228
231
../cfssl print-defaults csr > csr.json
229
232
230
- <!--
231
- 1 . Create a JSON config file for generating the CA file, for example, `ca-config.json`:
232
- -->
233
- 1 . 创建一个 JSON 配置文件来生成 CA 文件,例如:` ca-config.json ` :
233
+ <!--
234
+ 3 . Create a JSON config file for generating the CA file, for example, `ca-config.json`:
235
+ -->
236
+ 3 . 创建一个 JSON 配置文件来生成 CA 文件,例如:` ca-config.json ` :
234
237
235
238
{
236
239
"signing": {
@@ -251,12 +254,12 @@ Finally, add the same parameters into the API server start parameters.
251
254
}
252
255
}
253
256
254
- <!--
255
- 1 . Create a JSON config file for CA certificate signing request (CSR), for example,
256
- `ca-csr.json`. Be sure to replace the values marked with angle brackets with
257
- real values you want to use.
258
- -->
259
- 1 . 创建一个 JSON 配置文件,用于 CA 证书签名请求(CSR),例如:` ca-csr.json ` 。
257
+ <!--
258
+ 4 . Create a JSON config file for CA certificate signing request (CSR), for example,
259
+ `ca-csr.json`. Be sure to replace the values marked with angle brackets with
260
+ real values you want to use.
261
+ -->
262
+ 4 . 创建一个 JSON 配置文件,用于 CA 证书签名请求(CSR),例如:` ca-csr.json ` 。
260
263
确认用你需要的值替换掉尖括号中的值。
261
264
262
265
{
@@ -274,22 +277,22 @@ Finally, add the same parameters into the API server start parameters.
274
277
}]
275
278
}
276
279
277
- <!--
278
- 1 . Generate CA key (`ca-key.pem`) and certificate (`ca.pem`):
279
- -->
280
- 1 . 生成 CA 秘钥文件(` ca-key.pem ` )和证书文件(` ca.pem ` ):
280
+ <!--
281
+ 5 . Generate CA key (`ca-key.pem`) and certificate (`ca.pem`):
282
+ -->
283
+ 5 . 生成 CA 秘钥文件(` ca-key.pem ` )和证书文件(` ca.pem ` ):
281
284
282
285
../cfssl gencert -initca ca-csr.json | ../cfssljson -bare ca
283
286
284
- <!--
285
- 1 . Create a JSON config file for generating keys and certificates for the API
286
- server, for example, `server-csr.json`. Be sure to replace the values in angle brackets with
287
- real values you want to use. The `MASTER_CLUSTER_IP` is the service cluster
288
- IP for the API server as described in previous subsection.
289
- The sample below also assumes that you are using `cluster.local` as the default
290
- DNS domain name.
291
- -->
292
- 1 . 创建一个 JSON 配置文件,用来为 API 服务器生成秘钥和证书,例如:` server-csr.json ` 。
287
+ <!--
288
+ 6 . Create a JSON config file for generating keys and certificates for the API
289
+ server, for example, `server-csr.json`. Be sure to replace the values in angle brackets with
290
+ real values you want to use. The `MASTER_CLUSTER_IP` is the service cluster
291
+ IP for the API server as described in previous subsection.
292
+ The sample below also assumes that you are using `cluster.local` as the default
293
+ DNS domain name.
294
+ -->
295
+ 6 . 创建一个 JSON 配置文件,用来为 API 服务器生成秘钥和证书,例如:` server-csr.json ` 。
293
296
确认用你需要的值替换掉尖括号中的值。` MASTER_CLUSTER_IP ` 是为 API 服务器 指定的服务集群 IP,就像前面小节描述的那样。
294
297
以下示例假定你的默认 DNS 域名为` cluster.local ` 。
295
298
@@ -318,11 +321,11 @@ Finally, add the same parameters into the API server start parameters.
318
321
}]
319
322
}
320
323
321
- <!--
322
- 1 . Generate the key and certificate for the API server, which are by default
323
- saved into file `server-key.pem` and `server.pem` respectively:
324
- -->
325
- 1 . 为 API 服务器生成秘钥和证书,默认会分别存储为` server-key.pem ` 和 ` server.pem ` 两个文件。
324
+ <!--
325
+ 7 . Generate the key and certificate for the API server, which are by default
326
+ saved into file `server-key.pem` and `server.pem` respectively:
327
+ -->
328
+ 7 . 为 API 服务器生成秘钥和证书,默认会分别存储为` server-key.pem ` 和 ` server.pem ` 两个文件。
326
329
327
330
../cfssl gencert -ca=ca.pem -ca-key=ca-key.pem \
328
331
--config=ca-config.json -profile=kubernetes \
0 commit comments