Reputation: 925
I have a etcd cluster running on coreOS. The leader was set to the first member I've started (as expected), but I started the wrong one first, so the leader isn't who it's supposed to be.
How do I change the role of a leader to a different member?
Upvotes: 2
Views: 12324
Reputation: 1265
To change the leader in the etcd cluster you need to run a command:
etcdctl move-leader id-of-the-node-you-want-to-be-the-leader
To get id-of-the-node-you-want-to-be-the-leader
you need to run a command:
etcdctl endpoint status -w table
Full example with certificates and endpoints - you must adjust the parameters to your configuration of course. First get the table:
etcdctl endpoint status -w table \
--cacert="/ssl/client/ca-client.crt" \
--cert="/ssl/client/prod-v1-etcd-node-1-client.crt" \
--key="/ssl/client/prod-v1-etcd-node-1-client.key" \
--endpoints=127.0.0.1:2379,prod-v1-etcd-node-2:2379,prod-v1-etcd-node-3:2379
...then, change the leader:
etcdctl move-leader 1f648bfb63561530 \
--cacert="/ssl/client/ca-client.crt" \
--cert="/ssl/client/prod-v1-etcd-node-1-client.crt" \
--key="/ssl/client/prod-v1-etcd-node-1-client.key" \
--endpoints=127.0.0.1:2379,prod-v1-etcd-node-2:2379,prod-v1-etcd-node-3:2379
Upvotes: 2
Reputation: 925
I misunderstood the role of the etcd cluster leader. I was setting up a Kubernetes cluster and I thought the master node should be the etcd cluster leader. But as @heimbert mentioned the point of leader election is that you don't have to worry who the leader is.
Upvotes: 2