Skip to content

Commit 15e978d

Browse files
jiahuifTim BannisterChris Negus
authored
Leader Migration to GA (#32052)
* cleanup and polish. * update assumed versions. * GA updates. * Update content/en/docs/tasks/administer-cluster/controller-manager-leader-migration.md Co-authored-by: Tim Bannister <[email protected]> * Update content/en/docs/tasks/administer-cluster/controller-manager-leader-migration.md Co-authored-by: Tim Bannister <[email protected]> * Update content/en/docs/tasks/administer-cluster/controller-manager-leader-migration.md Co-authored-by: Chris Negus <[email protected]> Co-authored-by: Tim Bannister <[email protected]> Co-authored-by: Chris Negus <[email protected]>
1 parent f531bf4 commit 15e978d

File tree

1 file changed

+46
-11
lines changed

1 file changed

+46
-11
lines changed

content/en/docs/tasks/administer-cluster/controller-manager-leader-migration.md

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ Leader Migration provides a mechanism in which HA clusters can safely migrate "c
2121

2222
Leader Migration can be enabled by setting `--enable-leader-migration` on `kube-controller-manager` or `cloud-controller-manager`. Leader Migration only applies during the upgrade and can be safely disabled or left enabled after the upgrade is complete.
2323

24-
This guide walks you through the manual process of upgrading the control plane from `kube-controller-manager` with built-in cloud provider to running both `kube-controller-manager` and `cloud-controller-manager`. If you use a tool to administrator the cluster, please refer to the documentation of the tool and the cloud provider for more details.
24+
This guide walks you through the manual process of upgrading the control plane from `kube-controller-manager` with built-in cloud provider to running both `kube-controller-manager` and `cloud-controller-manager`. If you use a tool to deploy and manage the cluster, please refer to the documentation of the tool and the cloud provider for specific instructions of the migration.
2525

2626
## {{% heading "prerequisites" %}}
2727

28-
It is assumed that the control plane is running Kubernetes version N and to be upgraded to version N + 1. Although it is possible to migrate within the same version, ideally the migration should be performed as part of an upgrade so that changes of configuration can be aligned to each release. The exact versions of N and N + 1 depend on each cloud provider. For example, if a cloud provider builds a `cloud-controller-manager` to work with Kubernetes 1.22, then N can be 1.21 and N + 1 can be 1.22.
28+
It is assumed that the control plane is running Kubernetes version N and to be upgraded to version N + 1. Although it is possible to migrate within the same version, ideally the migration should be performed as part of an upgrade so that changes of configuration can be aligned to each release. The exact versions of N and N + 1 depend on each cloud provider. For example, if a cloud provider builds a `cloud-controller-manager` to work with Kubernetes 1.24, then N can be 1.23 and N + 1 can be 1.24.
2929

30-
The control plane nodes should run `kube-controller-manager` with Leader Election enabled through `--leader-elect=true`. As of version N, an in-tree cloud privider must be set with `--cloud-provider` flag and `cloud-controller-manager` should not yet be deployed.
30+
The control plane nodes should run `kube-controller-manager` with Leader Election enabled, which is the default. As of version N, an in-tree cloud provider must be set with `--cloud-provider` flag and `cloud-controller-manager` should not yet be deployed.
3131

32-
The out-of-tree cloud provider must have built a `cloud-controller-manager` with Leader Migration implementation. If the cloud provider imports `k8s.io/cloud-provider` and `k8s.io/controller-manager` of version v0.21.0 or later, Leader Migration will be available. However, for version before v0.22.0, Leader Migration is alpha and requires feature gate `ControllerManagerLeaderMigration` to be enabled.
32+
The out-of-tree cloud provider must have built a `cloud-controller-manager` with Leader Migration implementation. If the cloud provider imports `k8s.io/cloud-provider` and `k8s.io/controller-manager` of version v0.21.0 or later, Leader Migration will be available. However, for version before v0.22.0, Leader Migration is alpha and requires feature gate `ControllerManagerLeaderMigration` to be enabled in `cloud-controller-manager`.
3333

3434
This guide assumes that kubelet of each control plane node starts `kube-controller-manager` and `cloud-controller-manager` as static pods defined by their manifests. If the components run in a different setting, please adjust the steps accordingly.
3535

@@ -57,9 +57,8 @@ Leader Migration can be enabled without a configuration. Please see [Default Con
5757

5858
```yaml
5959
kind: LeaderMigrationConfiguration
60-
apiVersion: controllermanager.config.k8s.io/v1beta1
60+
apiVersion: controllermanager.config.k8s.io/v1
6161
leaderName: cloud-provider-extraction-migration
62-
resourceLock: leases
6362
controllerLeaders:
6463
- name: route
6564
component: kube-controller-manager
@@ -69,6 +68,23 @@ controllerLeaders:
6968
component: kube-controller-manager
7069
```
7170
71+
Alternatively, because the controllers can run under either controller managers, setting `component` to `*`
72+
for both sides makes the configuration file consistent between both parties of the migration.
73+
74+
```yaml
75+
# wildcard version
76+
kind: LeaderMigrationConfiguration
77+
apiVersion: controllermanager.config.k8s.io/v1
78+
leaderName: cloud-provider-extraction-migration
79+
controllerLeaders:
80+
- name: route
81+
component: *
82+
- name: service
83+
component: *
84+
- name: cloud-node-lifecycle
85+
component: *
86+
```
87+
7288
On each control plane node, save the content to `/etc/leadermigration.conf`, and update the manifest of `kube-controller-manager` so that the file is mounted inside the container at the same location. Also, update the same manifest to add the following arguments:
7389

7490
- `--enable-leader-migration` to enable Leader Migration on the controller manager
@@ -78,13 +94,12 @@ Restart `kube-controller-manager` on each node. At this moment, `kube-controller
7894

7995
### Deploy Cloud Controller Manager
8096

81-
In version N + 1, the desired state of controller-to-manager assignment can be represented by a new configuration file, shown as follows. Please note `component` field of each `controllerLeaders` changing from `kube-controller-manager` to `cloud-controller-manager`.
97+
In version N + 1, the desired state of controller-to-manager assignment can be represented by a new configuration file, shown as follows. Please note `component` field of each `controllerLeaders` changing from `kube-controller-manager` to `cloud-controller-manager`. Alternatively, use the wildcard version mentioned above, which has the same effect.
8298

8399
```yaml
84100
kind: LeaderMigrationConfiguration
85-
apiVersion: controllermanager.config.k8s.io/v1beta1
101+
apiVersion: controllermanager.config.k8s.io/v1
86102
leaderName: cloud-provider-extraction-migration
87-
resourceLock: leases
88103
controllerLeaders:
89104
- name: route
90105
component: cloud-controller-manager
@@ -94,9 +109,9 @@ controllerLeaders:
94109
component: cloud-controller-manager
95110
```
96111

97-
When creating control plane nodes of version N + 1, the content should be deploy to `/etc/leadermigration.conf`. The manifest of `cloud-controller-manager` should be updated to mount the configuration file in the same manner as `kube-controller-manager` of version N. Similarly, add `--enable-leader-migration` and `--leader-migration-config=/etc/leadermigration.conf` to the arguments of `cloud-controller-manager`.
112+
When creating control plane nodes of version N + 1, the content should be deployed to `/etc/leadermigration.conf`. The manifest of `cloud-controller-manager` should be updated to mount the configuration file in the same manner as `kube-controller-manager` of version N. Similarly, add `--enable-leader-migration` and `--leader-migration-config=/etc/leadermigration.conf` to the arguments of `cloud-controller-manager`.
98113

99-
Create a new control plane node of version N + 1 with the updated `cloud-controller-manager` manifest, and with the `--cloud-provider` flag unset for `kube-controller-manager`. `kube-controller-manager` of version N + 1 MUST NOT have Leader Migration enabled because, with an external cloud provider, it does not run the migrated controllers anymore and thus it is not involved in the migration.
114+
Create a new control plane node of version N + 1 with the updated `cloud-controller-manager` manifest, and with the `--cloud-provider` flag set to `external` for `kube-controller-manager`. `kube-controller-manager` of version N + 1 MUST NOT have Leader Migration enabled because, with an external cloud provider, it does not run the migrated controllers anymore, and thus it is not involved in the migration.
100115

101116
Please refer to [Cloud Controller Manager Administration](/docs/tasks/administer-cluster/running-cloud-controller/) for more detail on how to deploy `cloud-controller-manager`.
102117

@@ -120,6 +135,26 @@ The default configuration can be enabled by setting `--enable-leader-migration`
120135

121136
For `kube-controller-manager` and `cloud-controller-manager`, if there are no flags that enable any in-tree cloud provider or change ownership of controllers, the default configuration can be used to avoid manual creation of the configuration file.
122137

138+
### Special case: migrating the Node IPAM controller {#node-ipam-controller-migration}
139+
140+
If your cloud provider provides an implementation of Node IPAM controller, you should switch to the implementation in `cloud-controller-manager`. Disable Node IPAM controller in `kube-controller-manager` of version N + 1 by adding `--controllers=*,-nodeipam` to its flags. Then add `nodeipam` to the list of migrated controllers.
141+
142+
```yaml
143+
# wildcard version, with nodeipam
144+
kind: LeaderMigrationConfiguration
145+
apiVersion: controllermanager.config.k8s.io/v1
146+
leaderName: cloud-provider-extraction-migration
147+
controllerLeaders:
148+
- name: route
149+
component: *
150+
- name: service
151+
component: *
152+
- name: cloud-node-lifecycle
153+
component: *
154+
- name: nodeipam
155+
- component: *
156+
```
157+
123158
## {{% heading "whatsnext" %}}
124159

125160
- Read the [Controller Manager Leader Migration](https://github.com/kubernetes/enhancements/tree/master/keps/sig-cloud-provider/2436-controller-manager-leader-migration) enhancement proposal.

0 commit comments

Comments
 (0)