Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/damdo/k8s-haproxy-peer-sync
[POC, unmaintained] k8s sidecar for HAProxy in multi-replicas setups to keep HAProxy `peers` section in sync at runtime. Robust to scale-in/outs
https://github.com/damdo/k8s-haproxy-peer-sync
Last synced: 26 days ago
JSON representation
[POC, unmaintained] k8s sidecar for HAProxy in multi-replicas setups to keep HAProxy `peers` section in sync at runtime. Robust to scale-in/outs
- Host: GitHub
- URL: https://github.com/damdo/k8s-haproxy-peer-sync
- Owner: damdo
- Created: 2021-11-05T08:22:55.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-03T08:00:45.000Z (over 1 year ago)
- Last Synced: 2024-06-21T19:07:12.482Z (5 months ago)
- Language: Go
- Homepage:
- Size: 107 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## k8s-haproxy-peer-sync
#### WARNING:
This is a POC developed during an hackathon and thus this is not to be considered high quality code, nor production ready.
This is just a demonstration and may break unexpectedly, do not use in production as is.
Not actively maintained or used.### intro
A process to be run as a sidecar container inside an HAProxy multi-replicas Deployment/DaemonSet/StatefulSet (in Kubernetes) to keep the HAProxy `peers` section in sync at runtime.
Useful for keeping in-memory `stick-table`s in sync (through peers) across multiple HAProxy pod replicas.
Robust to scale-in/outs.
### try it out
0) Create a cluster where to deploy it.
As an example we'll use a [k8s kind](https://kind.sigs.k8s.io/) cluster here:
```
kind create cluster --name "kind" --config examples/cluster.yaml
```
0) Apply the Example sticky backend
```
kubectl --context kind-kind apply -f examples/sticky-backend.yaml
```
0) Apply the "Load balancer" as a single entrypoint to the kind cluster
```
kubectl --context kind-kind apply -f examples/lb.yaml
```
0) Apply the multi-replicas HAProxy setup with the k8s-haproxy-peer-sync sidecar
```
kubectl --context kind-kind apply -f examples/haproxy.yaml
```
0) Port forward the load balancer entrypoint to your local machine
```
kubectl --context kind-kind port-forward svc/lb 8080:8080
```Profit!
### test
Run some e2e tests against the kind cluster setup:
```
bash ./tests.sh http://127.0.0.1:8080
```You can inspect the 'syncer' logs via:
```
kubectl --context kind-kind logs -f haproxy- -c haproxy-peer-sync
```You can inspect the haproxy / haproxy Data Plane API logs via:
```
kubectl --context kind-kind logs -f haproxy- -c haproxy
```You can live debug the haproxy peers via:
```
kubectl --context kind-kind exec -it -c haproxy haproxy- -- sh -c 'apk add socat && watch -- "echo "show peers" | socat unix:/tmp/admin.sock -"'
```You can live debug the haproxy stick-table via:
```
# remember to change the table name if you change it in the config
kubectl --context kind-kind logs -f haproxy- -c haproxy -- sh -c 'apk add socat && watch -- "echo "show table back-session" | socat unix:/tmp/admin.sock -"'
```### TODO
- [ ] compose url string properly
- [x] dynamically generated user/password in initContainer for DataPlaneAPI basic auth cfg
- [x] DataPlaneAPI listen only on localhost
- [x] avoid crashing at the beginning?
- [ ] Lower logging levels on some less useful things