How to enable leader election for high-availability Kubernetes on Google Compute Engine?

2/27/2017

I'm trying to run kubernetes in high-availability mode on GCE following the instructions, but my kube-scheduler.manifest and kube-controller-manager.manifest don't have the --leader-elect=true flag set on any of the masters.

I dug around in the salt templates, and it appears to me that there is no configuration option to enable it. Further, the high-availability proposal suggests that the flag should be enabled even in "non-replicated mode", but it doesn't appear to be.

What is the proper way to enable leader election for kube-scheduler and kube-controller-manager? Is there a way to do it without resorting to modifying the salt tars myself?

The high-availability instructions mention enabling the --leader-elect flag, but the high-availability setup instructions don't explain exactly how to do it. The high-availability proposal doc says this about leader election: "We will use the same configuration in non-replicated mode to simplify deployment scripts", but I can't find evidence of that in the salt templates.

-- Jesse Shieh
google-compute-engine
high-availability
kubernetes

1 Answer

2/28/2017

The default value of the leader-elect flag is true as of Kubernetes v1.4.0, so in the absence of explicit configuration the leader election client should be enabled.

You may also want the set the apiserver-count flag of the Kubernetes API server according to the number of masters you spin-up (defaults to 1). It gives the master elected components (scheduler, controller-manager) a hint about the size of the quorum formed by the masters, because the leader election process uses the Raft consensus.

References:

-- Antoine Cotten
Source: StackOverflow