From 9e910320015460dc33bd5233854ad14221ef02e1 Mon Sep 17 00:00:00 2001 From: okozachenko Date: Tue, 2 Jun 2020 20:06:34 +0300 Subject: [PATCH] Add heat ingress Change-Id: I208dcb2494e21c630f85bb8c798b7e295c6821a2 --- config/samples/operator-config.yaml | 4 ++ openstack_operator/heat.py | 15 ++++++ .../templates/heat/ingress.yml.j2 | 54 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 openstack_operator/templates/heat/ingress.yml.j2 diff --git a/config/samples/operator-config.yaml b/config/samples/operator-config.yaml index 2045f809..20313b53 100644 --- a/config/samples/operator-config.yaml +++ b/config/samples/operator-config.yaml @@ -11,4 +11,8 @@ data: configDir: /etc/keystone heat: configDir: /etc/heat + ingress: + host: + api: "h-api.vexxhost.com" + api-cfn: "h-api-cfn.vexxhost.com" chronyd: {} \ No newline at end of file diff --git a/openstack_operator/heat.py b/openstack_operator/heat.py index b631be61..fc54e3f0 100644 --- a/openstack_operator/heat.py +++ b/openstack_operator/heat.py @@ -46,3 +46,18 @@ def create_or_resume(name, spec, **_): utils.create_or_update('heat/deployment.yml.j2', name=name, spec=spec, component='engine', config_hash=config_hash) + if "ingress" in spec: + utils.create_or_update('heat/ingress.yml.j2', + name=name, spec=spec) + + +@kopf.on.update('orchestration.openstack.org', 'v1alpha1', 'heats') +def update(name, spec, **_): + """Update a heat + + This function updates the deployment for heat if there are any + changes that happen within it. + """ + if "ingress" in spec: + utils.create_or_update('horizon/ingress.yml.j2', + name=name, spec=spec) diff --git a/openstack_operator/templates/heat/ingress.yml.j2 b/openstack_operator/templates/heat/ingress.yml.j2 new file mode 100644 index 00000000..0a94f1ff --- /dev/null +++ b/openstack_operator/templates/heat/ingress.yml.j2 @@ -0,0 +1,54 @@ +--- +# 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: extensions/v1beta1 +kind: Ingress +metadata: + name: heat + namespace: openstack + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + certmanager.k8s.io/cluster-issuer: "letsencrypt-prod" +spec: +{% if spec.ingress.host is defined %} + rules: + {% if spec.ingress.host.api is defined %} + - host: {{ spec.ingress.host.api }} + http: + paths: + - path: / + backend: + serviceName: heat-api + servicePort: 80 + {% endif %} + {% if spec.ingress.host["api-cfn"] is defined %} + - host: {{ spec.ingress.host["api-cfn"] }} + http: + paths: + - path: / + backend: + serviceName: heat-api-cfn + servicePort: 80 + {% endif %} + tls: + - hosts: + {% if spec.ingress.host.api is defined %} + - {{ spec.ingress.host.api }} + {% endif %} + {% if spec.ingress.host["api-cfn"] is defined %} + - {{ spec.ingress.host["api-cfn"] }} + {% endif %} + secretName: heat-tls +{% endif %} \ No newline at end of file