bunkerity / bunkerity/bunkerweb

[DOC] High availablity via keepalived

Open
#2,137 0 comments 0 reactions 0 assignees View on GitHub
docker documentation
Dominant language
Python
Stars
10.9k
Forks
643
Avg merge
1d 10h
Merged PRs (30d)
42

Description

### Description

I was able to get a proper HA setup without any additional loadbalancer in front of a Bunkerweb instance.
To do so I installed keepalived on my two Ubuntu VMs with following config:

##VM1
```json
! Configuration File for keepalived

global_defs {

vrrp_script chk_docker {
script "/etc/keepalived/docker.sh bunkerweb" # verify the pid existance
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}

vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 102
priority 111
advert_int 1
authentication {
auth_type PASS
auth_pass 4Ludwh3w
}
virtual_ipaddress {
10.0.20.19/24
}
track_script {
chk_docker
}
}
```

On VM2 I set `priority 110` so it stays as a backup.

The docker.sh script would be:
```bash
#!/bin/bash
if [ $(docker inspect --format="{{.State.Restarting}}" $1) = "false" ] && [ $(docker inspect --format="{{.State.Running}}" $1 2> /dev/null) = "true" ]; then
exit 0;
else
exit 1;
fi
```

The only thing that's currently missing is to have kind of a check as soon as Bunkerweb is fully available meaning it can handle traffic.
Running/healthy Bunkerweb is pulling the current config from the Bunkerweb scheduler before it starts handling traffic.

### Proposed solution (optional)

See abovr

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

No repository file or test is named. Start by reviewing the keepalived configuration and docker.sh example, then trace when Bunkerweb finishes pulling configuration from the scheduler and can handle traffic. Done means the HA check distinguishes a running container from a traffic-ready Bunkerweb instance and the setup is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, ubuntu
Domain
devops, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.