部署 Etcd 群集
Kubernetes 組件都是無狀態的,所有的群集狀態都儲存在 etcd 集群中。
本部分內容將部署一套三節點的 etcd 群集,並配置高可用以及遠程加密訪問。
事前準備
本部分的命令需要在每個控制節點上都運行一遍,包括 controller-0、controller-1 和 controller-2。可以使用 gcloud 命令登錄每個控制節點,比如
gcloud compute ssh controller-0可以使用 tmux 同時登錄到三點控制節點上,加快部署步驟。
部署 etcd 集群成員
下載並安裝 etcd 二進制文件
從 coreos/etcd GitHub 中下載 etcd 發佈文件:
wget -q --show-progress --https-only --timestamping \
"https://github.com/etcd-io/etcd/releases/download/v3.4.10/etcd-v3.4.10-linux-amd64.tar.gz"解壓縮並安裝 etcd 服務與 etcdctl 命令行工具:
{
tar -xvf etcd-v3.4.10-linux-amd64.tar.gz
sudo mv etcd-v3.4.10-linux-amd64/etcd* /usr/local/bin/
}配置 etcd Server
使用虛擬機的內網 IP 地址來作爲 etcd 集群的服務地址。查詢當前節點的內網 IP 地址:
每個 etcd 成員必須有一個整集群中唯一的名字,使用 hostname 作爲 etcd name:
生成 etcd.service 的 systemd 配置文件
啓動 etcd Server
不要忘記在所有控制節點上都運行上述命令,包括
controller-0、controller-1和controller-2等。
驗證
列出 etcd 的群集成員:
輸出
下一步:部署 Kubernetes 控制節點。
Last updated