Open arianvp opened 2 years ago
I didn't realize there was a Kubernetes Lease API. That's good to know. Yes, I think supporting that would be great. I'll tackle that once I get the project stabilized and tested. Thanks!
Following
@phillamb168 Just as a heads up there should be a "Subscribe" button on the right side of the PR if you want to get future notifications.
By the way here is the upstream example:
https://github.com/kubernetes/client-go/blob/v0.25.2/examples/leader-election/main.go
It uses a built-in leader elector loop which is maybe not what you want. So probably have to peek into https://github.com/kubernetes/client-go/blob/2fd4aac19007b97ef5b22d045b5615e2094200a1/tools/leaderelection/leaderelection.go#L243 and see how to hook it into litefs' loop
@arianvp Thanks for the example code. It looks like the loop is handled by the Kubernetes client and acquire()
and renew()
isn't accessible. I'll need to refactor the LiteFS code a bit so it can externalize the loop instead of handling it itself.
acquireOrRenew is implemented in terms of only public functions. So perhaps it's worth looking at its impl and mimicking it if you want to keep your own loop
But reusing the kubernetes loop might probably be more robust.
Just wanted to give a more visible thumbs up to this feature request.
I know people also want etcd and Zookeeper, and you mentioned this is lower priority, but at least I thought I would ask in case priorities have changed or if you have new opinions about this.
Kubernetes has something similar to consul sessions called the Lease API. Could we use it to simplify deployments in k8s so there is no dependency on consul?