Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gdamjan/k8s-leader-election-demo
Demo Leader Election with a Kubernetes Lease Object
https://github.com/gdamjan/k8s-leader-election-demo
demo kubernetes python
Last synced: 14 days ago
JSON representation
Demo Leader Election with a Kubernetes Lease Object
- Host: GitHub
- URL: https://github.com/gdamjan/k8s-leader-election-demo
- Owner: gdamjan
- Created: 2024-10-31T04:33:51.000Z (19 days ago)
- Default Branch: main
- Last Pushed: 2024-10-31T04:36:01.000Z (19 days ago)
- Last Synced: 2024-10-31T05:22:43.993Z (19 days ago)
- Topics: demo, kubernetes, python
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Leader Election with a K8s Lease
## Quickstart
Build docker image:
```
podman build -t leader-election .
podman run -it --rm -p 8000:8000 leader-election# push to local k3s registry
podman push --tls-verify=false leader-election registry.localhost/leader-election
```## Testing on a local k3s
Apply the deployment to your Kubernetes cluster:
```
k3s kubectl apply -k k8s/
```Verify the Lease: You can verify that the lease is created and check which pod holds the lease:
```
k3s kubectl get lease leader-lease -o yaml
```Follow logs of all pods:
```
k3s kubectl logs -l app=leader-election --all-containers=true -f --max-log-requests 10
```Run a pod with curl to access the web page:
```
k3s kubectl run curl -it --rm --image=quay.io/curl/curl-base:latest --command -- /bin/sh
# curl -v http://leader-election# curl -v http://leader-election/crash -d 'crash random pod'
```