https://github.com/kevinpollet/k8s-leader-election
Leader election example leveraging the the k8s client.
https://github.com/kevinpollet/k8s-leader-election
go k8s leader-election
Last synced: 7 months ago
JSON representation
Leader election example leveraging the the k8s client.
- Host: GitHub
- URL: https://github.com/kevinpollet/k8s-leader-election
- Owner: kevinpollet
- License: mit
- Created: 2021-11-04T22:06:17.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-21T21:15:14.000Z (almost 4 years ago)
- Last Synced: 2025-01-24T11:44:36.528Z (9 months ago)
- Topics: go, k8s, leader-election
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# k8s-leader-election
Leader election example leveraging the [leaderelection](https://github.com/kubernetes/client-go/tree/master/tools/leaderelection) pkg from the k8s [client](https://github.com/kubernetes/client-go#readme).
## Usage
1. Create a k3d cluster: `make cluster`
2. Deploy the leader-election app: `make deploy`
3. Get the current lease holder:```kubectl get lease leader-election -o=jsonpath='{.spec.holderIdentity}'```
5. Kill the current lease holder:
```kubectl delete pod $(kubectl get lease leader-election -o=jsonpath='{.spec.holderIdentity}')```
7. After waiting the `leaseDuration` period (`60s`) a new leader will be elected.
## License
[MIT](./LICENSE.md)