aboutsummaryrefslogtreecommitdiff
path: root/docker/centos/binary
diff options
context:
space:
mode:
authorMichal Jastrzebski (inc0) <michal.jastrzebski@intel.com>2015-06-02 04:54:15 +0200
committerMichal Jastrzebski (inc0) <michal.jastrzebski@intel.com>2015-06-22 17:18:44 +0200
commit52f49094356ca70495e3bc606751d55104726881 (patch)
treee7f66b145f3400a9d3134c469fcd0220dcbd0252 /docker/centos/binary
parent2dbde4ad8e2dfdc89701cae48a1fc77f5489ddda (diff)
downloadkolla-52f49094356ca70495e3bc606751d55104726881.tar.gz
kolla-52f49094356ca70495e3bc606751d55104726881.zip
Keepalived container
This patch contains keepalived container for yum-based distros. Change-Id: I8e3ea7a61ad6c27b25b635e7aeeff5ef04a807b4 Implements: blueprint keepalived-container
Diffstat (limited to 'docker/centos/binary')
-rwxr-xr-xdocker/centos/binary/keepalived/Dockerfile13
l---------docker/centos/binary/keepalived/build1
-rwxr-xr-xdocker/centos/binary/keepalived/check_alive.sh7
-rwxr-xr-xdocker/centos/binary/keepalived/keepalived.conf19
-rwxr-xr-xdocker/centos/binary/keepalived/start.sh29
5 files changed, 69 insertions, 0 deletions
diff --git a/docker/centos/binary/keepalived/Dockerfile b/docker/centos/binary/keepalived/Dockerfile
new file mode 100755
index 000000000..f24954990
--- /dev/null
+++ b/docker/centos/binary/keepalived/Dockerfile
@@ -0,0 +1,13 @@
+FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%base:%%KOLLA_TAG%%
+MAINTAINER Kolla Project (https://launchpad.net/kolla)
+
+RUN yum -y install \
+ hostname \
+ keepalived \
+ socat \
+ && yum clean all
+
+COPY keepalived.conf /etc/keepalived/
+
+COPY start.sh check_alive.sh /
+CMD ["/start.sh"]
diff --git a/docker/centos/binary/keepalived/build b/docker/centos/binary/keepalived/build
new file mode 120000
index 000000000..8d652f7ee
--- /dev/null
+++ b/docker/centos/binary/keepalived/build
@@ -0,0 +1 @@
+../../../../tools/build-docker-image \ No newline at end of file
diff --git a/docker/centos/binary/keepalived/check_alive.sh b/docker/centos/binary/keepalived/check_alive.sh
new file mode 100755
index 000000000..ee0c5a85b
--- /dev/null
+++ b/docker/centos/binary/keepalived/check_alive.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+# This is noop check script. Change it to something meaningful.
+# TODO (inc0): When HAProxy is implemented, this should be changed to HAProxy check
+# https://github.com/stackforge/kolla/blob/master/specs/high-availability.rst
+
+exit 0
diff --git a/docker/centos/binary/keepalived/keepalived.conf b/docker/centos/binary/keepalived/keepalived.conf
new file mode 100755
index 000000000..2a58fc018
--- /dev/null
+++ b/docker/centos/binary/keepalived/keepalived.conf
@@ -0,0 +1,19 @@
+vrrp_script check_alive {
+ script "/check_alive.sh"
+ interval 2
+ weight -10
+}
+
+vrrp_instance Floating {
+ state MASTER
+ interface @PUBLIC_INTERFACE@
+ virtual_router_id 51
+ priority @KEEPALIVED_PRIORITY@
+ advert_int 1
+ virtual_ipaddress {
+ @PUBLIC_IP@
+ }
+ track_script {
+ check_alive
+ }
+}
diff --git a/docker/centos/binary/keepalived/start.sh b/docker/centos/binary/keepalived/start.sh
new file mode 100755
index 000000000..7f582b218
--- /dev/null
+++ b/docker/centos/binary/keepalived/start.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+. /opt/kolla/kolla-common.sh
+
+check_required_vars KEEPALIVED_HOST_PRIORITIES PUBLIC_IP PUBLIC_INTERFACE
+
+MY_HOSTNAME=`hostname`
+
+# here we unpack KEEPALIVED_HOST_PRIORITIES hostname:priority pairs and match
+# them with current hostname, if it's there
+for i in ${KEEPALIVED_HOST_PRIORITIES//,/ }; do
+ HOST_PRIORITY=(${i//:/ })
+ if [ "$MY_HOSTNAME" == "${HOST_PRIORITY[0]}" ]; then
+ KEEPALIVED_PRIORITY=${HOST_PRIORITY[1]}
+ fi
+done
+
+if [ -z "$KEEPALIVED_PRIORITY" ]; then
+ echo "ERROR: missing hostname in KEEPALIVED_HOST_PRIORITIES: $MY_HOSTNAME" >&2
+ exit 1
+fi
+
+sed -i '
+ s|@PUBLIC_INTERFACE@|'$PUBLIC_INTERFACE'|g
+ s|@PUBLIC_IP@|'$PUBLIC_IP'|g
+ s|@KEEPALIVED_PRIORITY@|'$KEEPALIVED_PRIORITY'|g
+' /etc/keepalived/keepalived.conf
+
+exec /usr/sbin/keepalived -nld -p /run/keepalived.pid