@@ -6,12 +6,14 @@ content_type: task
6
6
reviewers:
7
7
- mml
8
8
- wojtek-t
9
+ - jpbetz
9
10
title: Operating etcd clusters for Kubernetes
10
11
content_type: task
11
12
-->
12
13
13
14
<!-- overview -->
14
- {{< glossary_definition term_id="etcd" length="all" >}}
15
+
16
+ {{< glossary_definition term_id="etcd" length="all" prepend="etcd 是 ">}}
15
17
16
18
## {{% heading "prerequisites" %}}
17
19
@@ -52,11 +54,11 @@ content_type: task
52
54
53
55
集群的性能和稳定性对网络和磁盘 I/O 非常敏感。任何资源匮乏都会导致心跳超时,
54
56
从而导致集群的不稳定。不稳定的情况表明没有选出任何主节点。
55
- 在这种情况下,集群不能对其当前状态进行任何更改,这意味着不能调度新的 pod 。
57
+ 在这种情况下,集群不能对其当前状态进行任何更改,这意味着不能调度新的 Pod 。
56
58
57
59
* 保持 etcd 集群的稳定对 Kubernetes 集群的稳定性至关重要。
58
- 因此,请在专用机器或隔离环境上运行 etcd 集群,以满足
59
- [ 所需资源需求] ( https://etcd.io/docs/current/op-guide/hardware/ ) 。
60
+ 因此,请在专用机器或隔离环境上运行 etcd 集群,
61
+ 以满足 [ 所需资源需求] ( https://etcd.io/docs/current/op-guide/hardware/ ) 。
60
62
61
63
* 在生产中运行的 etcd 的最低推荐版本是 ` 3.2.10+ ` 。
62
64
@@ -112,7 +114,7 @@ Use a single-node etcd cluster only for testing purpose.
112
114
113
115
2 . 使用参数 ` --etcd-servers=$PRIVATE_IP:2379 ` 启动 Kubernetes API 服务器。
114
116
115
- 确保将 ` PRIVATE_IP ` 设置为etcd客户端 IP。
117
+ 确保将 ` PRIVATE_IP ` 设置为 etcd 客户端 IP。
116
118
117
119
<!--
118
120
### Multi-node etcd cluster
@@ -180,7 +182,7 @@ To run a load balancing etcd cluster:
180
182
For example, let the address of the load balancer be `$LB`.
181
183
3. Start Kubernetes API Servers with the flag `--etcd-servers=$LB:2379`.
182
184
-->
183
- ### 使用负载均衡的多节点 etcd 集群 {#multi-node-etcd-cluster-with-load-balancer}
185
+ ### 使用负载均衡器的多节点 etcd 集群 {#multi-node-etcd-cluster-with-load-balancer}
184
186
185
187
要运行负载均衡的 etcd 集群:
186
188
@@ -284,17 +286,14 @@ flags `--etcd-certfile=k8sclient.cert`, `--etcd-keyfile=k8sclient.key` and
284
286
一旦正确配置了 etcd,只有具有有效证书的客户端才能访问它。要让 Kubernetes API 服务器访问,
285
287
可以使用参数 ` --etcd-certfile=k8sclient.cert ` 、` --etcd-keyfile=k8sclient.key ` 和 ` --etcd-cafile=ca.cert ` 配置。
286
288
287
- <!--
288
289
{{< note >}}
290
+ <!--
289
291
etcd authentication is not currently supported by Kubernetes. For more
290
292
information, see the related issue
291
293
[Support Basic Auth for Etcd v2](https://github.com/kubernetes/kubernetes/issues/23398).
292
- {{< /note >}}
293
294
-->
294
- {{< note >}}
295
295
Kubernetes 目前不支持 etcd 身份验证。
296
- 想要了解更多信息,请参阅相关的问题
297
- [ 支持 etcd v2 的基本认证] ( https://github.com/kubernetes/kubernetes/issues/23398 ) 。
296
+ 想要了解更多信息,请参阅相关的问题[ 支持 etcd v2 的基本认证] ( https://github.com/kubernetes/kubernetes/issues/23398 ) 。
298
297
{{< /note >}}
299
298
300
299
<!--
@@ -343,11 +342,36 @@ replace it with `member4=http://10.0.0.4`.
343
342
91bc3c398fb3c146, started, member2, http://10.0.0.2:2380, http://10.0.0.2:2379
344
343
fd422379fda50e48, started, member3, http://10.0.0.3:2380, http://10.0.0.3:2379
345
344
```
345
+ <!--
346
+ 2. Do either of the following:
347
+
348
+ 1. If each Kubernetes API server is configured to communicate with all etcd
349
+ members, remove the failed member from the `--etcd-servers` flag, then
350
+ restart each Kubernetes API server.
351
+ 1. If each Kubernetes API server communicates with a single etcd member,
352
+ then stop the Kubernetes API server that communicates with the failed
353
+ etcd.
354
+ -->
355
+ 2 . 执行以下操作之一:
356
+
357
+ 1 . 如果每个 Kubernetes API 服务器都配置为与所有 etcd 成员通信,
358
+ 请从 ` --etcd-servers ` 标志中移除删除失败的成员,然后重新启动每个 Kubernetes API 服务器。
359
+ 2 . 如果每个 Kubernetes API 服务器都与单个 etcd 成员通信,
360
+ 则停止与失败的 etcd 通信的 Kubernetes API 服务器。
361
+
362
+ <!--
363
+ 3. Stop the etcd server on the broken node. It is possible that other
364
+ clients besides the Kubernetes API server is causing traffic to etcd
365
+ and it is desirable to stop all traffic to prevent writes to the data
366
+ dir.
367
+ -->
368
+ 3 . 停止故障节点上的 etcd 服务器。除了 Kubernetes API 服务器之外的其他客户端可能会造成流向 etcd 的流量,
369
+ 可以停止所有流量以防止写入数据目录。
346
370
347
371
<!--
348
- 2 . Remove the failed member:
372
+ 4 . Remove the failed member:
349
373
-->
350
- 2 . 移除失败的成员
374
+ 4 . 移除失败的成员:
351
375
352
376
``` shell
353
377
etcdctl member remove 8211f1d0f64f3269
@@ -363,9 +387,9 @@ replace it with `member4=http://10.0.0.4`.
363
387
```
364
388
365
389
<!--
366
- 3 . Add the new member:
390
+ 5 . Add the new member:
367
391
-->
368
- 3 . 增加新成员:
392
+ 5 . 增加新成员:
369
393
370
394
``` shell
371
395
etcdctl member add member4 --peer-urls=http://10.0.0.4:2380
@@ -381,9 +405,9 @@ replace it with `member4=http://10.0.0.4`.
381
405
```
382
406
383
407
<!--
384
- 4 . Start the newly added member on a machine with the IP `10.0.0.4`:
408
+ 6 . Start the newly added member on a machine with the IP `10.0.0.4`:
385
409
-->
386
- 4 . 在 IP 为 ` 10.0.0.4 ` 的机器上启动新增加的成员:
410
+ 6 . 在 IP 为 ` 10.0.0.4 ` 的机器上启动新增加的成员:
387
411
388
412
``` shell
389
413
export ETCD_NAME=" member4"
@@ -393,19 +417,24 @@ replace it with `member4=http://10.0.0.4`.
393
417
```
394
418
395
419
<!--
396
- 5 . Do either of the following:
420
+ 7 . Do either of the following:
397
421
398
- 1. Update the `--etcd-servers` flag for the Kubernetes API servers to make
399
- Kubernetes aware of the configuration changes, then restart the
400
- Kubernetes API servers.
401
- 2. Update the load balancer configuration if a load balancer is used in the
402
- deployment.
422
+ 1. If each Kubernetes API server is configured to communicate with all etcd
423
+ members, add the newly added member to the `--etcd-servers` flag, then
424
+ restart each Kubernetes API server.
425
+ 1. If each Kubernetes API server communicates with a single etcd member,
426
+ start the Kubernetes API server that was stopped in step 2. Then
427
+ configure Kubernetes API server clients to again route requests to the
428
+ Kubernetes API server that was stopped. This can often be done by
429
+ configuring a load balancer.
403
430
-->
404
- 5 . 执行以下操作之一:
431
+ 7 . 执行以下操作之一:
405
432
406
- 1 . 更新 Kubernetes API 服务器的 ` --etcd-servers ` 参数,使 Kubernetes
407
- 知道配置已更改,然后重新启动 Kubernetes API 服务器。
408
- 2 . 如果在 deployment 中使用了负载均衡,更新负载均衡配置。
433
+ 1 . 如果每个 Kubernetes API 服务器都配置为与所有 etcd 成员通信,
434
+ 则将新增的成员添加到 ` --etcd-servers ` 标志,然后重新启动每个 Kubernetes API 服务器。
435
+ 2 . 如果每个 Kubernetes API 服务器都与单个 etcd 成员通信,请启动在第 2 步中停止的 Kubernetes API 服务器。
436
+ 然后配置 Kubernetes API 服务器客户端以再次将请求路由到已停止的 Kubernetes API 服务器。
437
+ 这通常可以通过配置负载均衡器来完成。
409
438
410
439
<!--
411
440
For more information on cluster reconfiguration, see
@@ -428,7 +457,8 @@ snapshot and volume snapshot.
428
457
-->
429
458
## 备份 etcd 集群 {#backing-up-an-etcd-cluster}
430
459
431
- 所有 Kubernetes 对象都存储在 etcd 上。定期备份 etcd 集群数据对于在灾难场景(例如丢失所有控制平面节点)下恢复 Kubernetes 集群非常重要。
460
+ 所有 Kubernetes 对象都存储在 etcd 上。
461
+ 定期备份 etcd 集群数据对于在灾难场景(例如丢失所有控制平面节点)下恢复 Kubernetes 集群非常重要。
432
462
快照文件包含所有 Kubernetes 状态和关键信息。为了保证敏感的 Kubernetes 数据的安全,可以对快照文件进行加密。
433
463
434
464
备份 etcd 集群可以通过两种方式完成:etcd 内置快照和卷快照。
@@ -459,6 +489,7 @@ Below is an example for taking a snapshot of the keyspace served by
459
489
``` shell
460
490
ETCDCTL_API=3 etcdctl --endpoints $ENDPOINT snapshot save snapshotdb
461
491
```
492
+
462
493
<!--
463
494
Verify the snapshot:
464
495
-->
@@ -544,7 +575,7 @@ one, when more reliability is desired. See
544
575
for information on how to add members into an existing cluster.
545
576
-->
546
577
合理的扩展是在需要更高可靠性的情况下,将三成员集群升级为五成员集群。
547
- 请参阅 [ etcd 重新配置文档 ] ( https://etcd.io/docs/current/op-guide/runtime-configuration/#remove-a-member )
578
+ 请参阅 [ etcd 重构文档 ] ( https://etcd.io/docs/current/op-guide/runtime-configuration/#remove-a-member )
548
579
以了解如何将成员添加到现有集群中的信息。
549
580
550
581
<!--
@@ -602,8 +633,9 @@ used in front of an etcd cluster, you might need to update the load balancer
602
633
instead.
603
634
-->
604
635
如果还原的集群的访问 URL 与前一个集群不同,则必须相应地重新配置 Kubernetes API 服务器。
605
- 在本例中,使用参数 ` --etcd-servers=$NEW_ETCD_CLUSTER ` 而不是参数 ` --etcd-servers=$OLD_ETCD_CLUSTER ` 重新启动 Kubernetes API 服务器。
606
- 用相应的 IP 地址替换 ` $NEW_ETCD_CLUSTER ` 和 ` $OLD_ETCD_CLUSTER ` 。如果在 etcd 集群前面使用负载平衡,则可能需要更新负载均衡器。
636
+ 在本例中,使用参数 ` --etcd-servers=$NEW_ETCD_CLUSTER ` 而不是参数 ` --etcd-servers=$OLD_ETCD_CLUSTER `
637
+ 重新启动 Kubernetes API 服务器。用相应的 IP 地址替换 ` $NEW_ETCD_CLUSTER ` 和 ` $OLD_ETCD_CLUSTER ` 。
638
+ 如果在 etcd 集群前面使用负载均衡,则可能需要更新负载均衡器。
607
639
608
640
<!--
609
641
If the majority of etcd members have permanently failed, the etcd cluster is
@@ -613,10 +645,11 @@ can be scheduled. In such cases, recover the etcd cluster and potentially
613
645
reconfigure Kubernetes API servers to fix the issue.
614
646
-->
615
647
如果大多数 etcd 成员永久失败,则认为 etcd 集群失败。在这种情况下,Kubernetes 不能对其当前状态进行任何更改。
616
- 虽然已调度的 pod 可能继续运行,但新的 pod 无法调度。在这种情况下,恢复 etcd 集群并可能需要重新配置 Kubernetes API 服务器以修复问题。
648
+ 虽然已调度的 Pod 可能继续运行,但新的 Pod 无法调度。在这种情况下,
649
+ 恢复 etcd 集群并可能需要重新配置 Kubernetes API 服务器以修复问题。
617
650
618
- <!--
619
651
{{< note >}}
652
+ <!--
620
653
If any API servers are running in your cluster, you should not attempt to
621
654
restore instances of etcd. Instead, follow these steps to restore etcd:
622
655
@@ -628,17 +661,15 @@ We also recommend restarting any components (e.g. `kube-scheduler`,
628
661
`kube-controller-manager`, `kubelet`) to ensure that they don't rely on some
629
662
stale data. Note that in practice, the restore takes a bit of time. During the
630
663
restoration, critical components will lose leader lock and restart themselves.
631
- {{< /note >}}
632
664
-->
633
- {{< note >}}
634
665
如果集群中正在运行任何 API 服务器,则不应尝试还原 etcd 的实例。相反,请按照以下步骤还原 etcd:
635
666
636
667
- 停止** 所有** API 服务实例
637
668
- 在所有 etcd 实例中恢复状态
638
669
- 重启所有 API 服务实例
639
670
640
- 我们还建议重启所有组件(例如 ` kube-scheduler ` 、` kube-controller-manager ` 、` kubelet ` ),以确保它们不会
641
- 依赖一些过时的数据 。请注意,实际中还原会花费一些时间。
671
+ 我们还建议重启所有组件(例如 ` kube-scheduler ` 、` kube-controller-manager ` 、` kubelet ` ),
672
+ 以确保它们不会依赖一些过时的数据 。请注意,实际中还原会花费一些时间。
642
673
在还原过程中,关键组件将丢失领导锁并自行重启。
643
674
{{< /note >}}
644
675
@@ -652,12 +683,10 @@ For more details on etcd upgrade, please refer to the [etcd upgrades](https://et
652
683
-->
653
684
有关 etcd 升级的更多详细信息,请参阅 [ etcd 升级] ( https://etcd.io/docs/latest/upgrades/ ) 文档。
654
685
655
- <!--
656
686
{{< note >}}
687
+ <!--
657
688
Before you start an upgrade, please back up your etcd cluster first.
658
- {{< /note >}}
659
689
-->
660
- {{< note >}}
661
690
在开始升级之前,请先备份你的 etcd 集群。
662
691
{{< /note >}}
663
692
0 commit comments