Merge "Ceph container"

This commit is contained in:
Jenkins 2015-08-30 09:49:35 +00:00 committed by Gerrit Code Review
commit 47383f37c5
9 changed files with 138 additions and 0 deletions

View File

@ -183,6 +183,7 @@ RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com 199369E5404BD
&& apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com F78372A06FF50C80464FC1B4F7B8CEA6056E8E56 \
&& apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com 430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A \
&& apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com 7D5C473EB80C00FC133071068A6844A29F68104E \
&& apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com 7F6C9F236D170493FCF404F27EBFDD5D17ED316D \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get dist-upgrade -y \

View File

@ -20,3 +20,6 @@ deb http://repo.percona.com/apt trusty main
# RabbitMQ repo. Despite the name, the 'testing' repo is the stable repo.
deb http://www.rabbitmq.com/debian/ testing main
# Ceph repo
deb http://ceph.com/debian-hammer/ trusty main

View File

@ -0,0 +1,17 @@
FROM {{ namespace }}/{{ base_distro }}-{{ install_type }}-base:{{ tag }}
MAINTAINER Kolla Project (https://launchpad.net/kolla)
{% if base_distro in ['fedora', 'centos', 'oraclelinux'] %}
RUN yum -y install ceph \
&& yum clean all
{% elif base_distro in ['ubuntu', 'debian'] %}
RUN apt-get install -y --no-install-recommends \
ceph \
parted \
hdparm \
&& apt-get clean
{% endif %}

View File

@ -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"]

View File

@ -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

View File

@ -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

View File

@ -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"]

View File

@ -0,0 +1,10 @@
#!/bin/bash
SOURCE="/opt/kolla/ceph-osd/ceph.conf"
TARGET="/etc/ceph/ceph.conf"
OWNER="ceph"
if [[ -f "$SOURCE" ]]; then
cp $SOURCE $TARGET
chown ${OWNER}: $TARGET
chmod 0644 $TARGET
fi

View File

@ -0,0 +1,35 @@
#!/bin/bash
set -o errexit
CMD="/usr/bin/ceph-osd"
ARGS="-f -d -i ${OSD_ID} --osd-journal ${OSD_DIR}/journal -k ${OSD_DIR}/keyring"
# 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
# Creating a new label for the disk
parted "${OSD_DEV}" -s -- mklabel gpt
# Preparing the OSD for use with Ceph
ceph-disk prepare "${OSD_DEV}"
OSD_ID="$(ceph osd create)"
OSD_DIR="/var/lib/ceph/osd/ceph-${OSD_ID}"
mkdir -p "${OSD_DIR}"
mount "${OSD_DEV}1" "${OSD_DIR}"
ceph-osd -i "${OSD_ID}" --mkfs --mkkey
ceph auth add "osd.${OSD_ID}" osd 'allow *' mon 'allow proflie osd' -i "${OSD_DIR}/keyring"
# Adding osd to crush map
ceph osd crush add-bucket "$(hostname)" host
ceph osd crush move "$(hostname)" root=default
ceph osd crush add "${OSD_ID}" "${OSD_INITIAL_WEIGHT}" host="$(hostname)"
exit 0
fi
exec $CMD $ARGS