docs
This commit is contained in:
parent
59869d4a53
commit
3e42563339
39
README.md
39
README.md
|
@ -5,7 +5,7 @@
|
|||
A docker image to run Keepalived.
|
||||
> [keepalived.org](http://keepalived.org/)
|
||||
|
||||
/!\ this documentation is a work in progress.
|
||||
|
||||
|
||||
## Quick start
|
||||
|
||||
|
@ -13,6 +13,32 @@ This image require the kernel module ip_vs loaded on the host (`modprobe ip_vs`)
|
|||
|
||||
docker run --cap-add=NET_ADMIN --net=host -d osixia/keepalived:0.2.0
|
||||
|
||||
## Beginner Guide
|
||||
|
||||
### Use your own Keepalived config
|
||||
This image comes with a keepalived config file that can be easily customized via environment variables for a quick bootstrap,
|
||||
but setting your own keepalived.conf is possible. 2 options:
|
||||
|
||||
- Link your config file at run time to `/container/service/keepalived/assets/keepalived.conf` :
|
||||
|
||||
docker run --volume /data/my-keepalived.conf:/container/service/keepalived/assets/keepalived.conf --detach osixia/keepalived:0.2.0
|
||||
|
||||
- Add your config file by extending or cloning this image, please refer to the [Advanced User Guide](#advanced-user-guide)
|
||||
|
||||
### Debug
|
||||
|
||||
The container default log level is **info**.
|
||||
Available levels are: `none`, `error`, `warning`, `info`, `debug` and `trace`.
|
||||
|
||||
Example command to run the container in `debug` mode:
|
||||
|
||||
docker run --detach osixia/keepalived:0.2.0 --loglevel debug
|
||||
|
||||
See all command line options:
|
||||
|
||||
docker run osixia/keepalived:0.2.0 --help
|
||||
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Environment variables defaults are set in **image/environment/default.yaml**
|
||||
|
@ -48,13 +74,13 @@ See how to [set your own environment variables](#set-your-own-environment-variab
|
|||
|
||||
Environment variable can be set directly by adding the -e argument in the command line, for example :
|
||||
|
||||
docker run -e KEEPALIVED_INTERFACE="eno1" -e KEEPALIVED_PASSWORD="password!" \
|
||||
-e KEEPALIVED_PRIORITY="100" -d osixia/keepalived
|
||||
docker run --env KEEPALIVED_INTERFACE="eno1" --env KEEPALIVED_PASSWORD="password!" \
|
||||
--env KEEPALIVED_PRIORITY="100" --detach osixia/keepalived
|
||||
|
||||
Or by setting your own `env.yaml` file as a docker volume to `/container/environment/env.yaml`
|
||||
|
||||
docker run -v /data/my-env.yaml:/container/environment/env.yaml \
|
||||
-d osixia/keepalived
|
||||
docker run --volume /data/my-env.yaml:/container/environment/env.yaml \
|
||||
--detach osixia/keepalived
|
||||
|
||||
### Set your own environment variables
|
||||
|
||||
|
@ -89,6 +115,7 @@ Dockerfile example:
|
|||
FROM osixia/osixia/keepalived:0.2.0
|
||||
MAINTAINER Your Name <your@name.com>
|
||||
|
||||
ADD keepalived.conf /container/service/keepalived/assets/keepalived.conf
|
||||
ADD environment /container/environment/01-custom
|
||||
ADD scripts.sh /container/service/keepalived/assets/notify.sh
|
||||
|
||||
|
@ -110,6 +137,8 @@ Adapt Makefile, set your image NAME and VERSION, for example :
|
|||
NAME = billy-the-king/keepalived
|
||||
VERSION = 0.1.0
|
||||
|
||||
Add your custom scripts, environment files, config ...
|
||||
|
||||
Build your image :
|
||||
|
||||
make build
|
||||
|
|
|
@ -5,41 +5,42 @@
|
|||
log-helper level eq trace && set -x
|
||||
|
||||
FIRST_START_DONE="${CONTAINER_STATE_DIR}/docker-keepalived-first-start-done"
|
||||
|
||||
# container first start
|
||||
if [ ! -e "$FIRST_START_DONE" ]; then
|
||||
|
||||
ln -sf ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf /etc/keepalived/keepalived.conf
|
||||
|
||||
#
|
||||
# bootstrap config
|
||||
#
|
||||
sed -i --follow-symlinks "s|{{ keepalived_interface }}|$KEEPALIVED_INTERFACE|g" /etc/keepalived/keepalived.conf
|
||||
sed -i --follow-symlinks "s|{{ keepalived_priority }}|$KEEPALIVED_PRIORITY|g" /etc/keepalived/keepalived.conf
|
||||
sed -i --follow-symlinks "s|{{ keepalived_password }}|$KEEPALIVED_PASSWORD|g" /etc/keepalived/keepalived.conf
|
||||
sed -i "s|{{ keepalived_interface }}|$KEEPALIVED_INTERFACE|g" ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf
|
||||
sed -i "s|{{ keepalived_priority }}|$KEEPALIVED_PRIORITY|g" ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf
|
||||
sed -i "s|{{ keepalived_password }}|$KEEPALIVED_PASSWORD|g" ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf
|
||||
|
||||
if [ -n "$KEEPALIVED_NOTIFY" ]; then
|
||||
sed -i --follow-symlinks "s|{{ keepalived_notify }}|notify \"$KEEPALIVED_NOTIFY\"|g" /etc/keepalived/keepalived.conf
|
||||
sed -i "s|{{ keepalived_notify }}|notify \"$KEEPALIVED_NOTIFY\"|g" ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf
|
||||
chmod +x $KEEPALIVED_NOTIFY
|
||||
else
|
||||
sed -i --follow-symlinks "/{{ keepalived_notify }}/d" /etc/keepalived/keepalived.conf
|
||||
sed -i "/{{ keepalived_notify }}/d" ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf
|
||||
fi
|
||||
|
||||
# unicast peers
|
||||
for peer in $(complex-bash-env iterate "${KEEPALIVED_UNICAST_PEERS}")
|
||||
do
|
||||
sed -i --follow-symlinks "s|{{ keepalived_unicast_peers }}|${peer}\n {{ keepalived_unicast_peers }}|g" /etc/keepalived/keepalived.conf
|
||||
sed -i "s|{{ keepalived_unicast_peers }}|${peer}\n {{ keepalived_unicast_peers }}|g" ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf
|
||||
done
|
||||
sed -i --follow-symlinks "/{{ keepalived_unicast_peers }}/d" /etc/keepalived/keepalived.conf
|
||||
sed -i "/{{ keepalived_unicast_peers }}/d" ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf
|
||||
|
||||
# virtual ips
|
||||
for vip in $(complex-bash-env iterate "${KEEPALIVED_VIRTUAL_IPS}")
|
||||
do
|
||||
sed -i --follow-symlinks "s|{{ keepalived_virtual_ips }}|${vip}\n {{ keepalived_virtual_ips }}|g" /etc/keepalived/keepalived.conf
|
||||
sed -i "s|{{ keepalived_virtual_ips }}|${vip}\n {{ keepalived_virtual_ips }}|g" ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf
|
||||
done
|
||||
sed -i --follow-symlinks "/{{ keepalived_virtual_ips }}/d" /etc/keepalived/keepalived.conf
|
||||
sed -i "/{{ keepalived_virtual_ips }}/d" ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf
|
||||
|
||||
touch $FIRST_START_DONE
|
||||
fi
|
||||
|
||||
if [ ! -e "/etc/backup-manager.conf" ]; then
|
||||
ln -sf ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf /etc/keepalived/keepalived.conf
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue