@@ -32,24 +32,15 @@ manually through `easyrsa`, `openssl` or `cfssl`.
32
32
33
33
<!--
34
34
1. Download, unpack, and initialize the patched version of easyrsa3.
35
- -->
36
-
37
- 1 . 下载、解压并初始化 easyrsa3 的补丁版本。
38
35
39
36
curl -LO https://storage.googleapis.com/kubernetes-release/easy-rsa/easy-rsa.tar.gz
40
37
tar xzf easy-rsa.tar.gz
41
38
cd easy-rsa-master/easyrsa3
42
39
./easyrsa init-pki
43
-
44
- <!--
45
- 1. Generate a CA. (`--batch` set automatic mode. `--req-cn` default CN to use.)
46
- -->
47
-
48
- 1 . 生成 CA(通过 ` --batch ` 参数设置自动模式。 通过 ` --req-cn ` 设置默认使用的 CN)
40
+ 1. Generate a new certificate authority (CA). `--batch` sets automatic mode;
41
+ `--req-cn` specifies the Common Name (CN) for the CA's new root certificate.
49
42
50
43
./easyrsa --batch "--req-cn=${MASTER_IP}@`date +%s`" build-ca nopass
51
-
52
- <!--
53
44
1. Generate server certificate and key.
54
45
The argument `--subject-alt-name` sets the possible IPs and DNS names the API server will
55
46
be accessed with. The `MASTER_CLUSTER_IP` is usually the first IP from the service CIDR
@@ -58,8 +49,33 @@ manually through `easyrsa`, `openssl` or `cfssl`.
58
49
after which the certificate expires.
59
50
The sample below also assumes that you are using `cluster.local` as the default
60
51
DNS domain name.
52
+
53
+ ./easyrsa --subject-alt-name="IP:${MASTER_IP},"\
54
+ "IP:${MASTER_CLUSTER_IP},"\
55
+ "DNS:kubernetes,"\
56
+ "DNS:kubernetes.default,"\
57
+ "DNS:kubernetes.default.svc,"\
58
+ "DNS:kubernetes.default.svc.cluster,"\
59
+ "DNS:kubernetes.default.svc.cluster.local" \
60
+ --days=10000 \
61
+ build-server-full server nopass
62
+ 1. Copy `pki/ca.crt`, `pki/issued/server.crt`, and `pki/private/server.key` to your directory.
63
+ 1. Fill in and add the following parameters into the API server start parameters:
64
+
65
+ --client-ca-file=/yourdirectory/ca.crt
66
+ --tls-cert-file=/yourdirectory/server.crt
67
+ --tls-private-key-file=/yourdirectory/server.key
61
68
-->
62
69
70
+ 1 . 下载、解压并初始化 easyrsa3 的补丁版本。
71
+
72
+ curl -LO https://storage.googleapis.com/kubernetes-release/easy-rsa/easy-rsa.tar.gz
73
+ tar xzf easy-rsa.tar.gz
74
+ cd easy-rsa-master/easyrsa3
75
+ ./easyrsa init-pki
76
+ 1 . 生成 CA(通过 ` --batch ` 参数设置自动模式。 通过 ` --req-cn ` 设置默认使用的 CN)
77
+
78
+ ./easyrsa --batch "--req-cn=${MASTER_IP}@`date +%s`" build-ca nopass
63
79
1 . 生成服务器证书和密钥。
64
80
参数 ` --subject-alt-name ` 设置了访问 API 服务器时可能使用的 IP 和 DNS 名称。 ` MASTER_CLUSTER_IP `
65
81
通常为 ` --service-cluster-ip-range ` 参数中指定的服务 CIDR 的 首个 IP 地址,` --service-cluster-ip-range ` 同时用于
@@ -75,12 +91,6 @@ manually through `easyrsa`, `openssl` or `cfssl`.
75
91
"DNS:kubernetes.default.svc.cluster.local" \
76
92
--days=10000 \
77
93
build-server-full server nopass
78
-
79
- <!--
80
- 1. Copy `pki/ca.crt`, `pki/issued/server.crt`, and `pki/private/server.key` to your directory.
81
- 1. Fill in and add the following parameters into the API server start parameters:
82
- -->
83
-
84
94
1 . 拷贝 ` pki/ca.crt ` 、 ` pki/issued/server.crt ` 和 ` pki/private/server.key ` 至您的目录。
85
95
1 . 填充并在 API 服务器的启动参数中添加以下参数:
86
96
@@ -94,40 +104,79 @@ manually through `easyrsa`, `openssl` or `cfssl`.
94
104
**openssl** can manually generate certificates for your cluster.
95
105
96
106
1. Generate a ca.key with 2048bit:
97
- -->
98
-
99
- 使用 ** openssl** 能够手动地为集群生成证书。
100
-
101
- 1 . 生成密钥位数为 2048 的 ca.key:
102
107
103
108
openssl genrsa -out ca.key 2048
104
-
105
- <!--
106
109
1. According to the ca.key generate a ca.crt (use -days to set the certificate effective time):
107
- -->
108
-
109
- 1 . 依据 ca.key 生成 ca.crt (使用 -days 参数来设置证书有效时间):
110
110
111
111
openssl req -x509 -new -nodes -key ca.key -subj "/CN=${MASTER_IP}" -days 10000 -out ca.crt
112
-
113
- <!--
114
112
1. Generate a server.key with 2048bit:
115
- -->
116
-
117
- 1 . 生成密钥位数为 2048 的 server.key:
118
113
119
114
openssl genrsa -out server.key 2048
120
-
121
- <!--
122
115
1. Create a config file for generating a Certificate Signing Request (CSR).
123
116
Be sure to substitute the values marked with angle brackets (e.g. `<MASTER_IP>`)
124
117
with real values before saving this to a file (e.g. `csr.conf`).
125
118
Note that the value for `MASTER_CLUSTER_IP` is the service cluster IP for the
126
119
API server as described in previous subsection.
127
120
The sample below also assumes that you are using `cluster.local` as the default
128
121
DNS domain name.
122
+
123
+ [ req ]
124
+ default_bits = 2048
125
+ prompt = no
126
+ default_md = sha256
127
+ req_extensions = req_ext
128
+ distinguished_name = dn
129
+
130
+ [ dn ]
131
+ C = <country>
132
+ ST = <state>
133
+ L = <city>
134
+ O = <organization>
135
+ OU = <organization unit>
136
+ CN = <MASTER_IP>
137
+
138
+ [ req_ext ]
139
+ subjectAltName = @alt_names
140
+
141
+ [ alt_names ]
142
+ DNS.1 = kubernetes
143
+ DNS.2 = kubernetes.default
144
+ DNS.3 = kubernetes.default.svc
145
+ DNS.4 = kubernetes.default.svc.cluster
146
+ DNS.5 = kubernetes.default.svc.cluster.local
147
+ IP.1 = <MASTER_IP>
148
+ IP.2 = <MASTER_CLUSTER_IP>
149
+
150
+ [ v3_ext ]
151
+ authorityKeyIdentifier=keyid,issuer:always
152
+ basicConstraints=CA:FALSE
153
+ keyUsage=keyEncipherment,dataEncipherment
154
+ extendedKeyUsage=serverAuth,clientAuth
155
+ subjectAltName=@alt_names
156
+ 1. Generate the certificate signing request based on the config file:
157
+
158
+ openssl req -new -key server.key -out server.csr -config csr.conf
159
+ 1. Generate the server certificate using the ca.key, ca.crt and server.csr:
160
+
161
+ openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key \
162
+ -CAcreateserial -out server.crt -days 10000 \
163
+ -extensions v3_ext -extfile csr.conf
164
+ 1. View the certificate:
165
+
166
+ openssl x509 -noout -text -in ./server.crt
129
167
-->
130
168
169
+ 使用 ** openssl** 能够手动地为集群生成证书。
170
+
171
+ 1 . 生成密钥位数为 2048 的 ca.key:
172
+
173
+ openssl genrsa -out ca.key 2048
174
+ 1 . 依据 ca.key 生成 ca.crt (使用 -days 参数来设置证书有效时间):
175
+
176
+ openssl req -x509 -new -nodes -key ca.key -subj "/CN=${MASTER_IP}" -days 10000 -out ca.crt
177
+ 1 . 生成密钥位数为 2048 的 server.key:
178
+
179
+ openssl genrsa -out server.key 2048
131
180
1 . 创建用于生成证书签名请求(CSR)的配置文件。
132
181
确保在将其保存至文件(如 ` csr.conf ` )之前将尖括号标记的值(如 ` <MASTER_IP> ` )
133
182
替换为你想使用的真实值。 注意:` MASTER_CLUSTER_IP ` 是前面小节中描述的 API 服务器的服务集群 IP
@@ -166,29 +215,14 @@ manually through `easyrsa`, `openssl` or `cfssl`.
166
215
keyUsage=keyEncipherment,dataEncipherment
167
216
extendedKeyUsage=serverAuth,clientAuth
168
217
subjectAltName=@alt_names
169
-
170
- <!--
171
- 1. Generate the certificate signing request based on the config file:
172
- -->
173
-
174
218
1 . 基于配置文件生成证书签名请求:
175
219
176
220
openssl req -new -key server.key -out server.csr -config csr.conf
177
-
178
- <!--
179
- 1. Generate the server certificate using the ca.key, ca.crt and server.csr:
180
- -->
181
-
182
221
1 . 使用 ca.key、ca.crt 和 server.csr 生成服务器证书:
183
222
184
223
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key \
185
224
-CAcreateserial -out server.crt -days 10000 \
186
225
-extensions v3_ext -extfile csr.conf
187
-
188
- <!--
189
- 1. View the certificate:
190
- -->
191
-
192
226
1 . 查看证书:
193
227
194
228
openssl x509 -noout -text -in ./server.crt
@@ -211,34 +245,20 @@ Finally, add the same parameters into the API server start parameters.
211
245
1. Download, unpack and prepare the command line tools as shown below.
212
246
Note that you may need to adapt the sample commands based on the hardware
213
247
architecture and cfssl version you are using.
214
- -->
215
248
216
- 1 . 按如下所示的方式下载、解压并准备命令行工具。
217
- 注意:你可能需要基于硬件架构和你所使用的 cfssl 版本对示例命令进行修改。
218
-
219
- curl -L https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 -o cfssl
249
+ curl -L https://github.com/cloudflare/cfssl/releases/download/v1.4.1/cfssl_1.4.1_linux_amd64 -o cfssl
220
250
chmod +x cfssl
221
- curl -L https://pkg. cfssl.org/R1.2/cfssljson_linux-amd64 -o cfssljson
251
+ curl -L https://github.com/cloudflare/ cfssl/releases/download/v1.4.1/cfssljson_1.4.1_linux_amd64 -o cfssljson
222
252
chmod +x cfssljson
223
- curl -L https://pkg. cfssl.org/R1.2 /cfssl-certinfo_linux-amd64 -o cfssl-certinfo
253
+ curl -L https://github.com/cloudflare/ cfssl/releases/download/v1.4.1 /cfssl-certinfo_1.4.1_linux_amd64 -o cfssl-certinfo
224
254
chmod +x cfssl-certinfo
225
-
226
- <!--
227
255
1. Create a directory to hold the artifacts and initialize cfssl:
228
- -->
229
-
230
- 1 . 创建目录来存放物料,并初始化 cfssl:
231
256
232
257
mkdir cert
233
258
cd cert
234
259
../cfssl print-defaults config > config.json
235
260
../cfssl print-defaults csr > csr.json
236
-
237
- <!--
238
261
1. Create a JSON config file for generating the CA file, for example, `ca-config.json`:
239
- -->
240
-
241
- 1 . 创建用来生成 CA 文件的 JSON 配置文件,例如 ` ca-config.json ` :
242
262
243
263
{
244
264
"signing": {
@@ -258,15 +278,9 @@ Finally, add the same parameters into the API server start parameters.
258
278
}
259
279
}
260
280
}
261
-
262
- <!--
263
281
1. Create a JSON config file for CA certificate signing request (CSR), for example,
264
282
`ca-csr.json`. Be sure to replace the values marked with angle brackets with
265
283
real values you want to use.
266
- -->
267
-
268
- 1 . 创建用来生成 CA 证书签名请求(CSR)的 JSON 配置文件,例如 ` ca-csr.json ` 。
269
- 确保将尖括号标记的值替换为你想使用的真实值。
270
284
271
285
{
272
286
"CN": "kubernetes",
@@ -282,24 +296,103 @@ Finally, add the same parameters into the API server start parameters.
282
296
"OU": "<organization unit>"
283
297
}]
284
298
}
285
-
286
- <!--
287
299
1. Generate CA key (`ca-key.pem`) and certificate (`ca.pem`):
288
- -->
289
-
290
- 1 . 生成 CA 密钥(` ca-key.pem ` )和证书(` ca.pem ` ):
291
300
292
301
../cfssl gencert -initca ca-csr.json | ../cfssljson -bare ca
293
-
294
- <!--
295
302
1. Create a JSON config file for generating keys and certificates for the API
296
303
server, for example, `server-csr.json`. Be sure to replace the values in angle brackets with
297
304
real values you want to use. The `MASTER_CLUSTER_IP` is the service cluster
298
305
IP for the API server as described in previous subsection.
299
306
The sample below also assumes that you are using `cluster.local` as the default
300
307
DNS domain name.
308
+
309
+ {
310
+ "CN": "kubernetes",
311
+ "hosts": [
312
+ "127.0.0.1",
313
+ "<MASTER_IP>",
314
+ "<MASTER_CLUSTER_IP>",
315
+ "kubernetes",
316
+ "kubernetes.default",
317
+ "kubernetes.default.svc",
318
+ "kubernetes.default.svc.cluster",
319
+ "kubernetes.default.svc.cluster.local"
320
+ ],
321
+ "key": {
322
+ "algo": "rsa",
323
+ "size": 2048
324
+ },
325
+ "names": [{
326
+ "C": "<country>",
327
+ "ST": "<state>",
328
+ "L": "<city>",
329
+ "O": "<organization>",
330
+ "OU": "<organization unit>"
331
+ }]
332
+ }
333
+ 1. Generate the key and certificate for the API server, which are by default
334
+ saved into file `server-key.pem` and `server.pem` respectively:
335
+
336
+ ../cfssl gencert -ca=ca.pem -ca-key=ca-key.pem \
337
+ --config=ca-config.json -profile=kubernetes \
338
+ server-csr.json | ../cfssljson -bare server
301
339
-->
302
340
341
+ 1 . 按如下所示的方式下载、解压并准备命令行工具。
342
+ 注意:你可能需要基于硬件架构和你所使用的 cfssl 版本对示例命令进行修改。
343
+
344
+ curl -L https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 -o cfssl
345
+ chmod +x cfssl
346
+ curl -L https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 -o cfssljson
347
+ chmod +x cfssljson
348
+ curl -L https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 -o cfssl-certinfo
349
+ chmod +x cfssl-certinfo
350
+ 1 . 创建目录来存放物料,并初始化 cfssl:
351
+
352
+ mkdir cert
353
+ cd cert
354
+ ../cfssl print-defaults config > config.json
355
+ ../cfssl print-defaults csr > csr.json
356
+ 1 . 创建用来生成 CA 文件的 JSON 配置文件,例如 ` ca-config.json ` :
357
+
358
+ {
359
+ "signing": {
360
+ "default": {
361
+ "expiry": "8760h"
362
+ },
363
+ "profiles": {
364
+ "kubernetes": {
365
+ "usages": [
366
+ "signing",
367
+ "key encipherment",
368
+ "server auth",
369
+ "client auth"
370
+ ],
371
+ "expiry": "8760h"
372
+ }
373
+ }
374
+ }
375
+ }
376
+ 1 . 创建用来生成 CA 证书签名请求(CSR)的 JSON 配置文件,例如 ` ca-csr.json ` 。
377
+ 确保将尖括号标记的值替换为你想使用的真实值。
378
+
379
+ {
380
+ "CN": "kubernetes",
381
+ "key": {
382
+ "algo": "rsa",
383
+ "size": 2048
384
+ },
385
+ "names":[{
386
+ "C": "<country>",
387
+ "ST": "<state>",
388
+ "L": "<city>",
389
+ "O": "<organization>",
390
+ "OU": "<organization unit>"
391
+ }]
392
+ }
393
+ 1 . 生成 CA 密钥(` ca-key.pem ` )和证书(` ca.pem ` ):
394
+
395
+ ../cfssl gencert -initca ca-csr.json | ../cfssljson -bare ca
303
396
1 . 按如下所示的方式创建用来为 API 服务器生成密钥和证书的 JSON 配置文件。
304
397
确保将尖括号标记的值替换为你想使用的真实值。 ` MASTER_CLUSTER_IP ` 是前面小节中描述的
305
398
API 服务器的服务集群 IP。 下面的示例也假设用户使用 ` cluster.local ` 作为默认的 DNS 域名。
@@ -328,12 +421,6 @@ Finally, add the same parameters into the API server start parameters.
328
421
"OU": "<organization unit>"
329
422
}]
330
423
}
331
-
332
- <!--
333
- 1. Generate the key and certificate for the API server, which are by default
334
- saved into file `server-key.pem` and `server.pem` respectively:
335
- -->
336
-
337
424
1 . 为 API 服务器生成密钥和证书,生成的秘钥和证书分别默认保存在文件 ` server-key.pem `
338
425
和 ` server.pem ` 中:
339
426
0 commit comments