1. Identify which Kubernetes Control Node has the leader. For his run below etcdctl command. In below command for —endpoints give the https client address endpoint of each control node.
sudo ETCDCTL_API=3 etcdctl --endpoints=https://10.0.0.182:2379,https://10.0.0.236:2379,https://10.0.0.4:2379,https://10.0.0.155:2379,https://10.0.0.96:2379 --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key endpoint status -w table
Below is the sample output.
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| https://10.0.0.182:2379 | d5907367f2bc466 | 3.5.3 | 9.7 MB | false | false | 9 | 110761 | 110761 | |
| https://10.0.0.236:2379 | e1c82ddedc10c490 | 3.5.3 | 9.7 MB | false | false | 9 | 110761 | 110761 | |
| https://10.0.0.4:2379 | 86d10b822621f9cf | 3.5.3 | 9.7 MB | true | false | 9 | 110761 | 110761 | |
| https://10.0.0.155:2379 | 9869473a238b9297 | 3.5.3 | 9.6 MB | false | false | 9 | 110761 | 110761 | |
| https://10.0.0.96:2379 | c4438cde3e1e5536 | 3.5.3 | 9.5 MB | false | false | 9 | 110761 | 110761 | |
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
2. Run below etcdctl command to change the leader to new control node.
sudo ETCDCTL_API=3 etcdctl --endpoints=<end-points> --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key move-leader <member ID>
For example, below is the example command.
In below command for —endpoints give the https client address endpoint of each control node, Replace the leader ID in this case d5907367f2bc466 with the leader ID of the Control Node you wish to change the Leader to.
sudo ETCDCTL_API=3 etcdctl --endpoints=https://10.0.0.182:2379,https://10.0.0.236:2379,https://10.0.0.4:2379,https://10.0.0.155:2379,https://10.0.0.96:2379 --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key move-leader d5907367f2bc466
Below is the sample console output you would see.
Leadership transferred from 86d10b822621f9cf to d5907367f2bc466
3. Run above command in step (1) to check if the leader moved to new control node.
Below is example output. As you can see leader is changed now to member ID d5907367f2bc466
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| https://10.0.0.182:2379 | d5907367f2bc466 | 3.5.3 | 9.7 MB | true | false | 10 | 111728 | 111728 | |
| https://10.0.0.236:2379 | e1c82ddedc10c490 | 3.5.3 | 9.7 MB | false | false | 10 | 111728 | 111728 | |
| https://10.0.0.4:2379 | 86d10b822621f9cf | 3.5.3 | 9.7 MB | false | false | 10 | 111728 | 111728 | |
| https://10.0.0.155:2379 | 9869473a238b9297 | 3.5.3 | 9.6 MB | false | false | 10 | 111728 | 111728 | |
| https://10.0.0.96:2379 | c4438cde3e1e5536 | 3.5.3 | 9.5 MB | false | false | 10 | 111728 | 111728 | |
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+