How to develop an Operator which could have a master Pod working and a standby to do failover?

12/13/2017

There's a concept Operator in k8s which will could provide a CRD and do some operations when watching ADD/UPDATE/DELETE events of the CR.

It's a common method to deploy two services for the purpose of high availability, one as the master to respond to requests and the other as a standby to do failover. I have heard that in k8s, controllers could use this method to do HA and APIServer offers the functionality to select master between the two services.
I have searched a lot but couldn't find an example as to how to use this feature in Operator.

Any suggestions on how to do HA for Operator are appreciated.

-- flyer
high-availability
kubernetes

1 Answer

12/13/2017

Seems you are referring to procedure called leader election. There is nice blog post about leader election in kubernetes. Some internal kubernetes services requires this too, for example kube-scheduler, since at moment only one scheduler can work.

Also, you can use other ways for leader election, maybe your language have library for leader election, via consul, etcd, zookeeper, etc.

-- Slava Bacherikov
Source: StackOverflow