Add mysql cluster to magnum deployment

Change-Id: I326a9e971ebce094670972bd7f68fac86fa2252a
This commit is contained in:
okozachenko 2020-07-30 12:20:29 +03:00
parent 38859bafea
commit 2c39f82cd2
4 changed files with 26 additions and 18 deletions

View File

@ -24,5 +24,6 @@ configMap:
heat:
configDir: /etc/heat
magnum:
configDir: /etc/magnum
mysql:
size: 10Gi
chronyd: {}

View File

@ -16,6 +16,5 @@ data:
host:
api: "h-api.vexxhost.com"
api-cfn: "h-api-cfn.vexxhost.com"
magnum:
configDir: /etc/magnum
magnum: {}
chronyd: {}

View File

@ -141,7 +141,12 @@ function create_magnum_conf {
iniset $MAGNUM_CONF DEFAULT transport_url "rabbit://$MAGNUM_RABBITMQ_USERNAME:$MAGNUM_RABBITMQ_PASSWORD@rabbitmq-magnum:5672/"
iniset $MAGNUM_CONF DEFAULT host "$HOSTNAME"
iniset $MAGNUM_CONF database connection `database_connection_url magnum`
# Get mysql password
MAGNUM_DATABASE_USER=$(get_data_from_secret magnum-mysql openstack USER)
MAGNUM_DATABASE_PASSWORD=$(get_data_from_secret magnum-mysql openstack PASSWORD)
MAGNUM_DATABASE_NAME=$(get_data_from_secret magnum-mysql openstack DATABASE)
iniset $MAGNUM_CONF database connection "mysql+pymysql://$MAGNUM_DATABASE_USER:$MAGNUM_DATABASE_PASSWORD@magnum-mysql/$MAGNUM_DATABASE_NAME?charset=utf8"
iniset $MAGNUM_CONF api host "$MAGNUM_SERVICE_HOST"
if is_service_enabled tls-proxy; then
iniset $MAGNUM_CONF api port "$MAGNUM_SERVICE_PORT_INT"
@ -258,17 +263,12 @@ function create_magnum_cache_dir {
}
# init_magnum() - Initialize databases, etc.
# init_magnum()
function init_magnum {
kubectl create secret generic magnum-config --from-file=/etc/magnum/magnum.conf --from-file=/etc/magnum/api-paste.ini -n openstack
# NOTE: Permissions here are bad but it's temporary so we don't care as much.
sudo chmod -Rv 777 /etc/magnum
# Only do this step once on the API node for an entire cluster.
if is_service_enabled $DATABASE_BACKENDS; then
# (Re)create magnum database
recreate_database magnum
fi
}
# magnum_register_image - Register heat image for magnum with property os_distro

View File

@ -19,6 +19,7 @@ the appropriate deployments, an instance of Memcache, RabbitMQ and a database
server for the installation.
"""
from openstack_operator import database
from openstack_operator import utils
@ -29,6 +30,21 @@ def create_or_resume(name, spec, **_):
start the service up for the first time.
"""
# deploy mysql
if "mysql" not in spec:
spec["mysql"] = {}
database.ensure_mysql_cluster("magnum", spec["mysql"])
# deploy memcached
utils.create_or_update('magnum/memcached.yml.j2', spec=spec)
# deploy rabbitmq
if not utils.ensure_secret("openstack", "magnum-rabbitmq"):
utils.create_or_update('magnum/secret-rabbitmq.yml.j2',
password=utils.generate_password())
utils.create_or_update('magnum/rabbitmq.yml.j2', spec=spec)
# deploy magnum
config_hash = utils.generate_hash(spec)
for component in ("api", "conductor"):
utils.create_or_update('magnum/daemonset.yml.j2',
@ -38,14 +54,6 @@ def create_or_resume(name, spec, **_):
utils.create_or_update('magnum/service.yml.j2',
name=name)
utils.create_or_update('magnum/memcached.yml.j2', spec=spec)
# deploy rabbitmq
if not utils.ensure_secret("openstack", "magnum-rabbitmq"):
utils.create_or_update('magnum/secret-rabbitmq.yml.j2',
password=utils.generate_password())
utils.create_or_update('magnum/rabbitmq.yml.j2', spec=spec)
if "ingress" in spec:
utils.create_or_update('magnum/ingress.yml.j2',
name=name, spec=spec)