用 3 台 master 搭建 kubernetes 高可用集群,将 3 台 master 都关机后,如果只启动其中1台,运行 kubectl 命令时总是报下面的错误:
The connection to the server k8s-api:6443 was refused - did you specify the right host or port?
只要再启动1台,就恢复正常,难道高可用集群一定要至少 2 台 master 正常运行吗?
今天发现是因为 api-server 在这台服务器上无法启动
我猜是重启的顺序搞错了
在 stackoverflow 上找到了答案,当一共有 3 个 master 节点时,至少需要 2 个节点可用,api-server 才可以正常工作。
Kubernetes API works as long as Etcd cluster works. Etcd cluster works when there is quorum, so at least 2 of 3 Etcd pods are alive. If only 1 of 3 Etcd pod is alive - cluster goes to read-only state when no new pods can be scheduled and no resource creates/updates/deletes are allowed.
在 The Ultimate Guide to Disaster Recovery for Your Kubernetes Clusters 这篇博文中也提到了:
We are running 3 master Kubernetes cluster with 3 etcd members running on each master. If we lose one master, we can still recover the master because etcd quorum is intact. Now if we lose two masters, we need a mechanism to recover from such situations as well for production grade clusters.