aboutsummaryrefslogtreecommitdiff
path: root/docker/ceph/ceph-mon
diff options
context:
space:
mode:
authorrthallisey <rhallise@redhat.com>2015-08-19 12:37:27 -0400
committerSam Yaple <sam@yaple.net>2015-08-30 07:54:01 +0000
commit63a7d01639e9a48c20ae1ae368cfafad7ac6cd87 (patch)
treee39a2dfc7261bad13cd25e48979dff848d35e49c /docker/ceph/ceph-mon
parent2d4a261f2295f0db9b7fceee25c05fb5442773fa (diff)
downloadkolla-63a7d01639e9a48c20ae1ae368cfafad7ac6cd87.tar.gz
kolla-63a7d01639e9a48c20ae1ae368cfafad7ac6cd87.zip
Ceph container
Running ceph in a container requires 2 pieces: - ceph-mon - objectstorage-daemon (osd) Co-Authored-By: Sam Yaple <sam@yaple.net> Change-Id: I33e5baf72e4bc493889da0d796041acfd1a2cad3 Partially-Implements: blueprint ceph-container
Diffstat (limited to 'docker/ceph/ceph-mon')
-rw-r--r--docker/ceph/ceph-mon/Dockerfile.j27
-rw-r--r--docker/ceph/ceph-mon/config-external.sh10
-rw-r--r--docker/ceph/ceph-mon/start.sh48
3 files changed, 65 insertions, 0 deletions
diff --git a/docker/ceph/ceph-mon/Dockerfile.j2 b/docker/ceph/ceph-mon/Dockerfile.j2
new file mode 100644
index 000000000..e9d47fc70
--- /dev/null
+++ b/docker/ceph/ceph-mon/Dockerfile.j2
@@ -0,0 +1,7 @@
+FROM {{ namespace }}/{{ base_distro }}-{{ install_type }}-ceph-base:{{ tag }}
+MAINTAINER Kolla Project (https://launchpad.net/kolla)
+
+COPY start.sh /
+COPY config-external.sh /opt/kolla/
+
+CMD ["/start.sh"]
diff --git a/docker/ceph/ceph-mon/config-external.sh b/docker/ceph/ceph-mon/config-external.sh
new file mode 100644
index 000000000..75488239c
--- /dev/null
+++ b/docker/ceph/ceph-mon/config-external.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+SOURCE="/opt/kolla/ceph-mon/ceph.conf"
+TARGET="/etc/ceph/ceph.conf"
+OWNER="ceph"
+
+if [[ -f "$SOURCE" ]]; then
+ cp $SOURCE $TARGET
+ chown ${OWNER}: $TARGET
+ chmod 0644 $TARGET
+fi
diff --git a/docker/ceph/ceph-mon/start.sh b/docker/ceph/ceph-mon/start.sh
new file mode 100644
index 000000000..eb5d7f5af
--- /dev/null
+++ b/docker/ceph/ceph-mon/start.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+set -o errexit
+
+CMD="/usr/bin/ceph-mon"
+ARGS="-d -i ${MON_NAME} --public-addr ${MON_IP}:6789"
+
+# Setup common paths
+KEYRING_ADMIN="/etc/ceph/ceph.admin.keyring"
+KEYRING_MON="/etc/ceph/ceph.mon.keyring"
+MONMAP="/etc/ceph/ceph.monmap"
+MON_DIR="/var/lib/ceph/mon/ceph-$(hostname)"
+
+# Loading common functions.
+source /opt/kolla/kolla-common.sh
+
+# Execute config strategy
+set_configs
+
+# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
+# of the KOLLA_BOOTSTRAP variable being set, including empty.
+if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
+ # Lookup our fsid from the ceph.conf
+ FSID="$(awk '/^fsid/ {print $3; exit}' ${ceph_conf})"
+
+ # Generating initial keyrings and monmap
+ ceph-authtool --create-keyring "${KEYRING_MON}" --gen-key -n mon. --cap mon 'allow *'
+ ceph-authtool --create-keyring "${KEYRING_ADMIN}" --gen-key -n client.admin --set-uid=0 --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow'
+ ceph-authtool "${KEYRING_MON}" --import-keyring "${KEYRING_ADMIN}"
+ monmaptool --create --add "$(hostname)" "${MON_IP}" --fsid "${FSID}" "${MONMAP}"
+
+ # TODO(SamYaple): Return json parsible output to ansible
+ exit 0
+fi
+
+# This section runs on every mon that does not have a keyring already.
+if [[ ! -e "${MON_DIR}/keyring" ]]; then
+ KEYRING_TMP="/tmp/ceph.mon.keyring"
+
+ # Generate keyring for current monitor
+ ceph-authtool --create-keyring "${KEYRING_TMP}" --import-keyring "${KEYRING_ADMIN}"
+ ceph-authtool "${KEYRING_TMP}" --import-keyring "${KEYRING_MON}"
+ mkdir -p "${MON_DIR}"
+ ceph-mon --mkfs -i "$(hostname)" --monmap "${MONMAP}" --keyring "${KEYRING_TMP}"
+ rm "${KEYRING_TMP}"
+fi
+
+exec $CMD $ARGS