Add config-internal/config-external to Magnum containers

Partially Implements: Blueprint standard-start
Co-Authored-By: Swapnil Kulkarni <me@coolsvap.net>
Change-Id: I88103eba45f520a2709129072bb90555feb5c6ba
This commit is contained in:
digambar 2015-07-03 10:14:52 +05:30 committed by Swapnil Kulkarni
parent fcda6a06d8
commit e34b3b68fd
13 changed files with 97 additions and 44 deletions

View File

@ -8,4 +8,6 @@ RUN yum -y install \
ADD ./start.sh /start.sh ADD ./start.sh /start.sh
ADD ./check.sh /check.sh ADD ./check.sh /check.sh
COPY config-internal.sh config-external.sh /opt/kolla/
CMD ["/start.sh"] CMD ["/start.sh"]

View File

@ -0,0 +1 @@
../../../../common/magnum/magnum-api/config-external.sh

View File

@ -0,0 +1 @@
../../../../common/magnum/magnum-api/config-internal.sh

View File

@ -10,4 +10,7 @@ RUN yum -y install \
RUN cd /tmp && curl -L https://github.com/GoogleCloudPlatform/kubernetes/releases/download/v0.15.0/kubernetes.tar.gz -o /tmp/kubernetes.tar.gz && /usr/bin/tar -xzvf /tmp/kubernetes.tar.gz && cp -a /tmp/kubernetes/platforms/linux/amd64/kubectl /usr/bin/kubectl && rm -rf /tmp/kubernetes RUN cd /tmp && curl -L https://github.com/GoogleCloudPlatform/kubernetes/releases/download/v0.15.0/kubernetes.tar.gz -o /tmp/kubernetes.tar.gz && /usr/bin/tar -xzvf /tmp/kubernetes.tar.gz && cp -a /tmp/kubernetes/platforms/linux/amd64/kubectl /usr/bin/kubectl && rm -rf /tmp/kubernetes
ADD ./start.sh /start.sh ADD ./start.sh /start.sh
COPY config-internal.sh config-external.sh /opt/kolla/
CMD ["/start.sh"] CMD ["/start.sh"]

View File

@ -0,0 +1 @@
../../../../common/magnum/magnum-conductor/config-external.sh

View File

@ -0,0 +1 @@
../../../../common/magnum/magnum-conductor/config-internal.sh

View File

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

View File

@ -0,0 +1,27 @@
#!/bin/bash
set -e
. /opt/kolla/kolla-common.sh
. /opt/kolla/config-magnum.sh
check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \
MAGNUM_KEYSTONE_USER MAGNUM_KEYSTONE_PASSWORD \
KEYSTONE_AUTH_PROTOCOL ADMIN_TENANT_NAME \
MAGNUM_API_SERVICE_HOST KEYSTONE_ADMIN_SERVICE_PORT \
MAGNUM_API_SERVICE_PORT
fail_unless_os_service_running keystone
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0"
crux user-create -n ${MAGNUM_KEYSTONE_USER} \
-p ${MAGNUM_KEYSTONE_PASSWORD} \
-t ${ADMIN_TENANT_NAME} \
-r admin
crux endpoint-create --remove-all -n ${MAGNUM_KEYSTONE_USER} -t container \
-I "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1" \
-P "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1" \
-A "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1"
exec /usr/bin/magnum-api

View File

@ -1,27 +1,20 @@
#!/bin/bash #!/bin/bash
set -e
. /opt/kolla/kolla-common.sh set -o errexit
. /opt/kolla/config-magnum.sh CMD="/usr/bin/magnum-api"
ARGS=""
check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ # Loading common functions.
MAGNUM_KEYSTONE_USER MAGNUM_KEYSTONE_PASSWORD \ source /opt/kolla/kolla-common.sh
KEYSTONE_AUTH_PROTOCOL ADMIN_TENANT_NAME \
MAGNUM_API_SERVICE_HOST KEYSTONE_ADMIN_SERVICE_PORT \
MAGNUM_API_SERVICE_PORT
fail_unless_os_service_running keystone # Config-internal script exec out of this function, it does not return here.
set_configs
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}" # Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0" # of the KOLLA_BOOTSTRAP variable being set, including empty.
crux user-create -n ${MAGNUM_KEYSTONE_USER} \ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
-p ${MAGNUM_KEYSTONE_PASSWORD} \ su -s /bin/sh -c "magnum-manage db_sync" magnum
-t ${ADMIN_TENANT_NAME} \ exit 0
-r admin fi
crux endpoint-create --remove-all -n ${MAGNUM_KEYSTONE_USER} -t container \ exec $CMD $ARGS
-I "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1" \
-P "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1" \
-A "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1"
exec /usr/bin/magnum-api

View File

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

View File

@ -0,0 +1,17 @@
#!/bin/bash
. /opt/kolla/kolla-common.sh
. /opt/kolla/config-magnum.sh
check_required_vars MAGNUM_DB_NAME MAGNUM_DB_USER MAGNUM_DB_PASSWORD
fail_unless_db
mysql -h ${MARIADB_SERVICE_HOST} -u root -p${DB_ROOT_PASSWORD} mysql <<EOF
CREATE DATABASE IF NOT EXISTS ${MAGNUM_DB_NAME} DEFAULT CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON ${MAGNUM_DB_NAME}.* TO
'${MAGNUM_DB_USER}'@'%' IDENTIFIED BY '${MAGNUM_DB_PASSWORD}'
EOF
/usr/bin/magnum-db-manage upgrade
exec /usr/bin/magnum-conductor

View File

@ -1,17 +1,14 @@
#!/bin/bash #!/bin/bash
. /opt/kolla/kolla-common.sh set -o errexit
. /opt/kolla/config-magnum.sh
check_required_vars MAGNUM_DB_NAME MAGNUM_DB_USER MAGNUM_DB_PASSWORD CMD="/usr/bin/magnum-conductor"
fail_unless_db ARGS=""
mysql -h ${MARIADB_SERVICE_HOST} -u root -p${DB_ROOT_PASSWORD} mysql <<EOF # Loading common functions.
CREATE DATABASE IF NOT EXISTS ${MAGNUM_DB_NAME} DEFAULT CHARACTER SET utf8; source /opt/kolla/kolla-common.sh
GRANT ALL PRIVILEGES ON ${MAGNUM_DB_NAME}.* TO
'${MAGNUM_DB_USER}'@'%' IDENTIFIED BY '${MAGNUM_DB_PASSWORD}'
EOF
/usr/bin/magnum-db-manage upgrade # Config-internal script exec out of this function, it does not return here.
set_configs
exec /usr/bin/magnum-conductor exec $CMD $ARGS

View File

@ -300,15 +300,7 @@ In order for each service to function, there is a minimum set of required variab
# Magnum-api # Magnum-api
ADMIN_TENANT_NAME None
KEYSTONE_ADMIN_SERVICE_HOST
KEYSTONE_ADMIN_SERVICE_PORT
KEYSTONE_ADMIN_TOKEN
KEYSTONE_AUTH_PROTOCOL
MAGNUM_API_SERVICE_HOST
MAGNUM_API_SERVICE_PORT
MAGNUM_KEYSTONE_PASSWORD
MAGNUM_KEYSTONE_USER
# Magnum-base # Magnum-base
@ -327,9 +319,7 @@ In order for each service to function, there is a minimum set of required variab
# Magnum-conductor # Magnum-conductor
MAGNUM_DB_NAME None
MAGNUM_DB_PASSWORD
MAGNUM_DB_USER
# Mariadb # Mariadb