This repository has been archived on 2025-01-23. You can view files and clone it, but cannot push or open issues or pull requests.
traefik-certmanager/kubernetes/base/leaderelection
Tom Neuber 9129813244
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful
fix(kubernetes): temporary solution for updated k8s python client
2025-01-05 00:33:58 +01:00
..
resourcelock fix(kubernetes): temporary solution for updated k8s python client 2025-01-05 00:33:58 +01:00
__init__.py fix(kubernetes): temporary solution for updated k8s python client 2025-01-05 00:33:58 +01:00
electionconfig.py fix(kubernetes): temporary solution for updated k8s python client 2025-01-05 00:33:58 +01:00
example.py fix(kubernetes): temporary solution for updated k8s python client 2025-01-05 00:33:58 +01:00
leaderelection.py fix(kubernetes): temporary solution for updated k8s python client 2025-01-05 00:33:58 +01:00
leaderelection_test.py fix(kubernetes): temporary solution for updated k8s python client 2025-01-05 00:33:58 +01:00
leaderelectionrecord.py fix(kubernetes): temporary solution for updated k8s python client 2025-01-05 00:33:58 +01:00
README.md fix(kubernetes): temporary solution for updated k8s python client 2025-01-05 00:33:58 +01:00

Leader Election Example

This example demonstrates how to use the leader election library.

Running

Run the following command in multiple separate terminals preferably an odd number. Each running process uses a unique identifier displayed when it starts to run.

  • When a program runs, if a lock object already exists with the specified name, all candidates will start as followers.
  • If a lock object does not exist with the specified name then whichever candidate creates a lock object first will become the leader and the rest will be followers.
  • The user will be prompted about the status of the candidates and transitions.

Command to run

python example.py

Now kill the existing leader. You will see from the terminal outputs that one of the remaining running processes will be elected as the new leader.