Sorry for not posting the direct answer. I was struggling with coding up lease-based-master-election strategy in python. But I think this strategy is used for High Availibility only. Like scenarios where if the master fails, then the incoming requests should be quickly forwarded to the slaves.
But the catch is even when the master fails until the time is reached for which the lease was taken the incoming requests will be forwarded to the same master. So it will not be available for that time.
What my proposed design is - Keeping two pods with two different statefulset, a master and a slave. They both will be kept consistent asynchronously. And in the application level logic we can backoff exponentially and say for every even retry we try the master and for odd retry we try the slave. We can make more slaves to get higher availibility and in this way the downtime will be decreased dramatically.
Please let me know your opinion on this design.