My setup is similar to a active/passive deployment but I'd like to use the kubernetes lease and leader election to manage the active pod.
The leader election is all working as intended and the Lease object is created and maintained (roughly based on this post https://carlosbecker.com/posts/k8s-leader-election/ ), but I'm stuck when I try to use this lease information as a service selector and only send traffic to the active pod.
Fwiw, I have this info in the lease itself:
Spec:
Acquire Time: 2023-06-06T17:45:49.962378Z
Holder Identity: leader-test-585469899d-t84qx
Lease Duration Seconds: 15
Lease Transitions: 2
Renew Time: 2023-06-06T17:55:11.891018Z
Can anyone please give me some pointers how to get this to work?
I did play with the thought of adding logic to the leader-elector sidecar that can set a label on the active pod and use that as service selector, but then i realised this label would probably immediately get reverted by the deployment so I abandoned that idea.