From cf98ccccc95d1e81c56d6691ec333721c58e6133 Mon Sep 17 00:00:00 2001 From: Qiming Teng Date: Sun, 26 Jun 2022 13:15:11 +0800 Subject: [PATCH] [zh-cn] Resync setup etcd HA cluster page --- .../kubeadm/setup-ha-etcd-with-kubeadm.md | 83 +++++++++---------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/content/zh-cn/docs/setup/production-environment/tools/kubeadm/setup-ha-etcd-with-kubeadm.md b/content/zh-cn/docs/setup/production-environment/tools/kubeadm/setup-ha-etcd-with-kubeadm.md index 0fde3d0a86..0df3785c3a 100644 --- a/content/zh-cn/docs/setup/production-environment/tools/kubeadm/setup-ha-etcd-with-kubeadm.md +++ b/content/zh-cn/docs/setup/production-environment/tools/kubeadm/setup-ha-etcd-with-kubeadm.md @@ -76,20 +76,17 @@ The general approach is to generate all certs on one node and only distribute th {{< note >}} kubeadm 包含生成下述证书所需的所有必要的密码学工具;在这个例子中,不需要其他加密工具。 {{< /note >}} - - -{{< note >}} 下面的例子使用 IPv4 地址,但是你也可以使用 IPv6 地址配置 kubeadm、kubelet 和 etcd。一些 Kubernetes 选项支持双协议栈,但是 etcd 不支持。 关于 Kubernetes 双协议栈支持的更多细节,请参见 [kubeadm 的双栈支持](/zh-cn/docs/setup/production-environment/tools/kubeadm/dual-stack-support/)。 {{< /note >}} @@ -127,7 +124,6 @@ on Kubernetes dual-stack support see [Dual-stack support with kubeadm](/docs/set - 检查 kubelet 的状态以确保其处于运行状态: ```shell @@ -150,47 +146,47 @@ on Kubernetes dual-stack support see [Dual-stack support with kubeadm](/docs/set export HOST1=10.0.0.7 export HOST2=10.0.0.8 - # 使用你的主机名更新 NAME0, NAME1 和 NAME2 - export NAME0="infra0" - export NAME1="infra1" - export NAME2="infra2" + # 使用你的主机名更新 NAME0、NAME1 和 NAME2 + export NAME0="infra0" + export NAME1="infra1" + export NAME2="infra2" # 创建临时目录来存储将被分发到其它主机上的文件 mkdir -p /tmp/${HOST0}/ /tmp/${HOST1}/ /tmp/${HOST2}/ - HOSTS=(${HOST0} ${HOST1} ${HOST2}) - NAMES=(${NAME0} ${NAME1} ${NAME2}) + HOSTS=(${HOST0} ${HOST1} ${HOST2}) + NAMES=(${NAME0} ${NAME1} ${NAME2}) - for i in "${!HOSTS[@]}"; do - HOST=${HOSTS[$i]} - NAME=${NAMES[$i]} - cat << EOF > /tmp/${HOST}/kubeadmcfg.yaml - --- - apiVersion: "kubeadm.k8s.io/v1beta3" - kind: InitConfiguration - nodeRegistration: - name: ${NAME} - localAPIEndpoint: - advertiseAddress: ${HOST} - --- - apiVersion: "kubeadm.k8s.io/v1beta3" - kind: ClusterConfiguration - etcd: - local: - serverCertSANs: - - "${HOST}" - peerCertSANs: - - "${HOST}" - extraArgs: - initial-cluster: ${NAMES[0]}=https://${HOSTS[0]}:2380,${NAMES[1]}=https://${HOSTS[1]}:2380,${NAMES[2]}=https://${HOSTS[2]}:2380 - initial-cluster-state: new - name: ${NAME} - listen-peer-urls: https://${HOST}:2380 - listen-client-urls: https://${HOST}:2379 - advertise-client-urls: https://${HOST}:2379 - initial-advertise-peer-urls: https://${HOST}:2380 - EOF - done + for i in "${!HOSTS[@]}"; do + HOST=${HOSTS[$i]} + NAME=${NAMES[$i]} + cat << EOF > /tmp/${HOST}/kubeadmcfg.yaml + --- + apiVersion: "kubeadm.k8s.io/v1beta3" + kind: InitConfiguration + nodeRegistration: + name: ${NAME} + localAPIEndpoint: + advertiseAddress: ${HOST} + --- + apiVersion: "kubeadm.k8s.io/v1beta3" + kind: ClusterConfiguration + etcd: + local: + serverCertSANs: + - "${HOST}" + peerCertSANs: + - "${HOST}" + extraArgs: + initial-cluster: ${NAMES[0]}=https://${HOSTS[0]}:2380,${NAMES[1]}=https://${HOSTS[1]}:2380,${NAMES[2]}=https://${HOSTS[2]}:2380 + initial-cluster-state: new + name: ${NAME} + listen-peer-urls: https://${HOST}:2380 + listen-client-urls: https://${HOST}:2379 + advertise-client-urls: https://${HOST}:2379 + initial-advertise-peer-urls: https://${HOST}:2380 + EOF + done ``` - 这一操作创建如下两个文件 + 这一操作创建如下两个文件: - `/etc/kubernetes/pki/etcd/ca.crt` - `/etc/kubernetes/pki/etcd/ca.key` @@ -402,3 +398,4 @@ kubeadm](/docs/setup/independent/high-availability/). 一旦拥有了一个正常工作的 3 成员的 etcd 集群,你就可以基于 [使用 kubeadm 外部 etcd 的方法](/zh-cn/docs/setup/production-environment/tools/kubeadm/high-availability/), 继续部署一个高可用的控制平面。 +