website/content/zh-cn/docs/concepts/cluster-administration/coordinated-leader-election.md

3.2 KiB
Raw Permalink Blame History

title content_type weight
协调领导者选举 concept 200

{{< feature-state feature_gate_name="CoordinatedLeaderElection" >}}

Kubernetes {{< skew currentVersion >}} 包含一个 Beta 特性, 允许{{< glossary_tooltip text="控制平面" term_id="control-plane" >}}组件通过协调领导者选举确定性地选择一个领导者。 这对于在集群升级期间满足 Kubernetes 版本偏差约束非常有用。 目前,唯一内置的选择策略是 OldestEmulationVersion 此策略会优先选择最低仿真版本作为领导者,其次按二进制版本选择领导者,最后会按创建时间戳选择领导者。

启用协调领导者选举

确保你在启动 {{< glossary_tooltip text="API 服务器" term_id="kube-apiserver" >}}时 CoordinatedLeaderElection 特性门控被启用, 并且 coordination.k8s.io/v1beta1 API 组被启用。

此操作可以通过设置 --feature-gates="CoordinatedLeaderElection=true"--runtime-config="coordination.k8s.io/v1beta1=true" 标志来完成。

组件配置

前提是你已启用 CoordinatedLeaderElection 特性门控并且 启用了 coordination.k8s.io/v1beta1 API 组, 兼容的控制平面组件会自动使用 LeaseCandidate 和 Lease API 根据需要选举领导者。

对于 Kubernetes {{< skew currentVersion >}} 当特性门控和 API 组被启用时, 两个控制平面组件kube-controller-manager 和 kube-scheduler会自动使用协调领导者选举。