Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,28 @@ FakeIPA simulate the IPA by:
a queue of fake agents.
- Faking the sync/async commands needed by ironic to inspect,
clean and provision a node.

## Keepalived

Keepalived container used in Ironic deployments. Keepalived is used to
provide fixed IP address for Ironic in such a manner that even after pivoting
operations the IP of Ironic stays persistent.

[Keepalived documentation](https://www.keepalived.org/manpage.html)

Deployment configuration options:

- `CUSTOM_CONF_DIR` - when specified, a subdirectory (named keepalived) will be
created under this path then the config files will be moved to the subdirectory
and the variable substitution will happen in this subdirectory
- `CUSTOM_DATA_DIR` - subdirectory (named keepalived) will be created here to
hold the keepalived and vrrp pid files
- `PROVISIONING_IP` - the fixed IP provided by keepalived
- `PROVISIONING_INTERFACE` - The name of the interface that will be used
to "host" the fixed IP (keepalived is used in a pod that is attached to
host network, thus the interface names are the same as the interface names
on the host)

NOTE: If run with container that has read-only root file-system, then
`CUSTOM_CONF_DIR`, `CUSTOM_DATA_DIR` and `/var/log` paths have to mounted from
external volume.
19 changes: 16 additions & 3 deletions keepalived/manage-keepalived.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

set -eux

CUSTOM_CONF_DIR="${CUSTOM_CONF_DIR:-/conf}"
CUSTOM_DATA_DIR="${CUSTOM_DATA_DIR:-/data}"
KEEPALIVED_DEFAULT_CONF='/etc/keepalived/keepalived.conf'
KEEPALIVED_CONF_DIR="${CUSTOM_CONF_DIR}/keepalived"
KEEPALIVED_CONF="${KEEPALIVED_CONF_DIR}/keepalived.conf"
KEEPALIVED_DATA_DIR="${CUSTOM_DATA_DIR}/keepalived"

mkdir -p "${KEEPALIVED_CONF_DIR}" "${KEEPALIVED_DATA_DIR}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is broken without root

cp "${KEEPALIVED_DEFAULT_CONF}" "${KEEPALIVED_CONF}"

export assignedIP="${PROVISIONING_IP}/32"
export interface="${PROVISIONING_INTERFACE}"

sed -i "s~INTERFACE~${interface}~g" /etc/keepalived/keepalived.conf
sed -i "s~CHANGEIP~${assignedIP}~g" /etc/keepalived/keepalived.conf
sed -i "s~INTERFACE~${interface}~g" "${KEEPALIVED_CONF}"
sed -i "s~CHANGEIP~${assignedIP}~g" "${KEEPALIVED_CONF}"

exec /usr/sbin/keepalived -n -l -p /run/keepalived/keepalived.pid -r /run/keepalived/vrrp.pid
exec /usr/sbin/keepalived --dont-fork --log-console \
--pid="${KEEPALIVED_DATA_DIR}/keepalived.pid" \
--vrrp_pid="${KEEPALIVED_DATA_DIR}/vrrp.pid" \
--use-file="${KEEPALIVED_CONF}"