I have a HA cluster(say 3 masters with 1 kubes-scheduler pod on each master). There is a container running in each kube-scheduler pod. Inside this container, there two problems need to be solved here:
I know the "holderIdentity" field of the "...kubernetes.io/leader" annotation of the pod will tell the ID of the leader. Then the only question is how to know which pod the container is running on. Or there is a way I can simply know if the pod I'm running is a leader.
You can check the logs of kube-scheduler
. You shall see lock is held by <HolderIdentity> and has not yet expired
in the logs of non-leader Pods. And also successfully acquired lease
or successfully renewed lease
in the leader Pod logs.