|
| 1 | +--- |
| 2 | +title: 协调领导者选举 |
| 3 | +content_type: concept |
| 4 | +weight: 200 |
| 5 | +--- |
| 6 | +<!-- |
| 7 | +reviewers: |
| 8 | +- jpbetz |
| 9 | +title: Coordinated Leader Election |
| 10 | +content_type: concept |
| 11 | +weight: 200 |
| 12 | +--> |
| 13 | + |
| 14 | +<!-- overview --> |
| 15 | + |
| 16 | +{{< feature-state feature_gate_name="CoordinatedLeaderElection" >}} |
| 17 | + |
| 18 | +<!-- |
| 19 | +Kubernetes {{< skew currentVersion >}} includes an alpha feature that allows {{< |
| 20 | +glossary_tooltip text="control plane" term_id="control-plane" >}} components to |
| 21 | +deterministically select a leader via _coordinated leader election_. |
| 22 | +This is useful to satisfy Kubernetes version skew constraints during cluster upgrades. |
| 23 | +Currently, the only builtin selection strategy is `OldestEmulationVersion`, |
| 24 | +preferring the leader with the lowest emulation version, followed by binary |
| 25 | +version, followed by creation timestamp. |
| 26 | +--> |
| 27 | +Kubernetes {{< skew currentVersion >}} 包含一个 Alpha 特性, |
| 28 | +允许{{< glossary_tooltip text="控制平面" term_id="control-plane" >}}组件通过**协调领导者选举**确定性地选择一个领导者。 |
| 29 | +这对于在集群升级期间满足 Kubernetes 版本偏差约束非常有用。 |
| 30 | +目前,唯一内置的选择策略是 `OldestEmulationVersion`, |
| 31 | +此策略会优先选择最低仿真版本作为领导者,其次按二进制版本选择领导者,最后会按创建时间戳选择领导者。 |
| 32 | + |
| 33 | +<!-- |
| 34 | +## Enabling coordinated leader election |
| 35 | +
|
| 36 | +Ensure that `CoordinatedLeaderElection` [feature |
| 37 | +gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled |
| 38 | +when you start the {{< glossary_tooltip text="API Server" |
| 39 | +term_id="kube-apiserver" >}}: and that the `coordination.k8s.io/v1alpha1` API group is |
| 40 | +enabled. |
| 41 | +--> |
| 42 | +## 启用协调领导者选举 {#enabling-coordinated-leader-election} |
| 43 | + |
| 44 | +确保你在启动 {{< glossary_tooltip text="API 服务器" term_id="kube-apiserver" >}}时 |
| 45 | +`CoordinatedLeaderElection` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)被启用, |
| 46 | +并且 `coordination.k8s.io/v1alpha1` API 组被启用。 |
| 47 | + |
| 48 | +<!-- |
| 49 | +This can be done by setting flags `--feature-gates="CoordinatedLeaderElection=true"` and |
| 50 | +`--runtime-config="coordination.k8s.io/v1alpha1=true"`. |
| 51 | +--> |
| 52 | +此操作可以通过设置 `--feature-gates="CoordinatedLeaderElection=true"` |
| 53 | +和 `--runtime-config="coordination.k8s.io/v1alpha1=true"` 标志来完成。 |
| 54 | + |
| 55 | +<!-- |
| 56 | +## Component configuration |
| 57 | +
|
| 58 | +Provided that you have enabled the `CoordinatedLeaderElection` feature gate _and_ |
| 59 | +have the `coordination.k8s.io/v1alpha1` API group enabled, compatible control plane |
| 60 | +components automatically use the LeaseCandidate and Lease APIs to elect a leader |
| 61 | +as needed. |
| 62 | +--> |
| 63 | +## 组件配置 {#component-configuration} |
| 64 | + |
| 65 | +前提是你已启用 `CoordinatedLeaderElection` 特性门控**并且** |
| 66 | +启用了 `coordination.k8s.io/v1alpha1` API 组, |
| 67 | +兼容的控制平面组件会自动使用 LeaseCandidate 和 Lease API 根据需要选举领导者。 |
| 68 | + |
| 69 | +<!-- |
| 70 | +For Kubernetes {{< skew currentVersion >}}, two control plane components |
| 71 | +(kube-controller-manager and kube-scheduler) automatically use coordinated |
| 72 | +leader election when the feature gate and API group are enabled. |
| 73 | +--> |
| 74 | +对于 Kubernetes {{< skew currentVersion >}}, |
| 75 | +当特性门控和 API 组被启用时, |
| 76 | +两个控制平面组件(kube-controller-manager 和 kube-scheduler)会自动使用协调领导者选举。 |
0 commit comments