diff --git a/devstack/lib/magnum b/devstack/lib/magnum index 5aa3bc79..c50fb62b 100644 --- a/devstack/lib/magnum +++ b/devstack/lib/magnum @@ -133,7 +133,12 @@ function create_magnum_conf { rm -f $MAGNUM_CONF HOSTNAME=`hostname` iniset $MAGNUM_CONF DEFAULT debug "$ENABLE_DEBUG_LOG_LEVEL" - iniset $MAGNUM_CONF DEFAULT transport_url $(get_transport_url) + + # Get rabbitmq password + MAGNUM_RABBITMQ_PASSWORD=$(get_data_from_secret magnum-rabbitmq openstack password) + MAGNUM_RABBITMQ_USERNAME=$(get_data_from_secret magnum-rabbitmq openstack username) + + 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` diff --git a/openstack_operator/magnum.py b/openstack_operator/magnum.py index 448d7be2..ea8e643f 100644 --- a/openstack_operator/magnum.py +++ b/openstack_operator/magnum.py @@ -39,6 +39,12 @@ def create_or_resume(name, spec, **_): utils.create_or_update('magnum/service.yml.j2', name=name) + # 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') + if "ingress" in spec: utils.create_or_update('magnum/ingress.yml.j2', name=name, spec=spec) diff --git a/openstack_operator/objects.py b/openstack_operator/objects.py index feaaf173..c95a8d07 100644 --- a/openstack_operator/objects.py +++ b/openstack_operator/objects.py @@ -60,14 +60,6 @@ class PodMonitor(NamespacedAPIObject): kind = "PodMonitor" -class Rabbitmq(NamespacedAPIObject): - """Rabbitmq Kubernetes object""" - - version = "infrastructure.vexxhost.cloud/v1alpha1" - endpoint = "rabbitmqs" - kind = "Rabbitmq" - - class PrometheusRule(NamespacedAPIObject): """PrometheusRule Kubernetes object""" @@ -76,6 +68,14 @@ class PrometheusRule(NamespacedAPIObject): kind = "PrometheusRule" +class Rabbitmq(NamespacedAPIObject): + """Rabbitmq Kubernetes object""" + + version = "infrastructure.vexxhost.cloud/v1alpha1" + endpoint = "rabbitmqs" + kind = "Rabbitmq" + + MAPPING = { "v1": { "ConfigMap": ConfigMap, @@ -101,7 +101,7 @@ MAPPING = { "infrastructure.vexxhost.cloud/v1alpha1": { "Mcrouter": Mcrouter, "Memcached": Memcached, - "Rabbitmq": Rabbitmq, + "Rabbitmq": Rabbitmq }, "monitoring.coreos.com/v1": { "PodMonitor": PodMonitor, diff --git a/openstack_operator/templates/magnum/rabbitmq.yml.j2 b/openstack_operator/templates/magnum/rabbitmq.yml.j2 new file mode 100644 index 00000000..4a24208a --- /dev/null +++ b/openstack_operator/templates/magnum/rabbitmq.yml.j2 @@ -0,0 +1,30 @@ +--- +# Copyright 2020 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: infrastructure.vexxhost.cloud/v1alpha1 +kind: Rabbitmq +metadata: + name: magnum + namespace: openstack +spec: + authSecret: magnum-rabbitmq +{% if 'nodeSelector' in spec %} + nodeSelector: + {{ spec.nodeSelector | to_yaml | indent(4) }} +{% endif %} +{% if 'tolerations' in spec %} + tolerations: + {{ spec.tolerations | to_yaml | indent(4) }} +{% endif %} diff --git a/openstack_operator/templates/magnum/secret-rabbitmq.yml.j2 b/openstack_operator/templates/magnum/secret-rabbitmq.yml.j2 new file mode 100644 index 00000000..ddbbad7d --- /dev/null +++ b/openstack_operator/templates/magnum/secret-rabbitmq.yml.j2 @@ -0,0 +1,9 @@ + +apiVersion: v1 +metadata: + name: keystone-rabbitmq + namespace: openstack +stringData: + username: magnum + password: {{ password }} +kind: Secret \ No newline at end of file