From 3ed9b52fcf849a793fe220c788c13c08fd71186f Mon Sep 17 00:00:00 2001 From: okozachenko Date: Tue, 19 May 2020 18:44:43 +0300 Subject: [PATCH] Add keystone ingress Create a ingress with the host lists which are from the keystone CR spec Change-Id: I18c7f3f529e0e44e412b647345fc176bbcea93dc --- .../samples/identity_v1alpha1_keystone.yaml | 3 + openstack_operator/keystone.py | 15 +++++ .../templates/keystone/ingress.yml.j2 | 55 +++++++++++++++++++ playbooks/functional/tests/memcached.yaml | 4 +- playbooks/functional/tests/rabbitmq.yaml | 2 +- 5 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 openstack_operator/templates/keystone/ingress.yml.j2 diff --git a/config/samples/identity_v1alpha1_keystone.yaml b/config/samples/identity_v1alpha1_keystone.yaml index a9b3c4a9..722d01d6 100644 --- a/config/samples/identity_v1alpha1_keystone.yaml +++ b/config/samples/identity_v1alpha1_keystone.yaml @@ -5,3 +5,6 @@ metadata: name: sample spec: configDir: /etc/keystone + ingress: + - host: "keystone1.vexxhost.com" + - host: "keystone2.vexxhost.com" diff --git a/openstack_operator/keystone.py b/openstack_operator/keystone.py index 6f46476e..08b24228 100644 --- a/openstack_operator/keystone.py +++ b/openstack_operator/keystone.py @@ -39,3 +39,18 @@ def create_or_resume(name, spec, **_): name=name, spec=spec) utils.create_or_update('keystone/horizontalpodautoscaler.yml.j2', name=name) + if "ingress" in spec: + utils.create_or_update('keystone/ingress.yml.j2', + spec=spec) + + +@kopf.on.update('identity.openstack.org', 'v1alpha1', 'keystones') +def update(spec, **_): + """Update a keystone + + This function updates the deployment for horizon if there are any + changes that happen within it. + """ + if "ingress" in spec: + utils.create_or_update('keystone/ingress.yml.j2', + spec=spec) diff --git a/openstack_operator/templates/keystone/ingress.yml.j2 b/openstack_operator/templates/keystone/ingress.yml.j2 new file mode 100644 index 00000000..be60abe5 --- /dev/null +++ b/openstack_operator/templates/keystone/ingress.yml.j2 @@ -0,0 +1,55 @@ +--- +# 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: keystone + annotations: + kubernetes.io/ingress.class: "nginx" + cert-manager.io/cluster-issuer: "letsencrypt-prod" + certmanager.k8s.io/cluster-issuer: "letsencrypt-prod" +spec: +{% if spec.ingress.host is defined %} + rules: + - host: {{ spec.ingress.host }} + http: + paths: + - path: / + backend: + serviceName: keystone + servicePort: 80 + tls: + - hosts: + - {{ spec.ingress.host }} + secretName: keystone-tls +{% else %} + rules: + {% for v in spec.ingress %} + - host: {{ v.host }} + http: + paths: + - path: / + backend: + serviceName: keystone + servicePort: 80 + {% endfor %} + tls: + - hosts: + {% for v in spec.ingress %} + - {{ v.host }} + {% endfor %} + secretName: keystone-tls +{% endif %} \ No newline at end of file diff --git a/playbooks/functional/tests/memcached.yaml b/playbooks/functional/tests/memcached.yaml index 354e8493..e30fb5a1 100644 --- a/playbooks/functional/tests/memcached.yaml +++ b/playbooks/functional/tests/memcached.yaml @@ -38,7 +38,7 @@ register: _metrics loop: "{{ _memcached_ips.stdout_lines }}" until: _metrics is success - retries: 10 + retries: 60 delay: 5 failed_when: "'memcached_up 1' not in _metrics.content" @@ -46,7 +46,7 @@ command: kubectl get pods -l app.kubernetes.io/name=mcrouter,app.kubernetes.io/instance=memcached-devstack -o=jsonpath='{range .items[*]}{.status.podIP}{"\n"}{end}' register: _mcrouter_ips until: _mcrouter_ips is success - retries: 10 + retries: 60 delay: 5 failed_when: | {{ _mcrouter_ips.stdout_lines | length == 0 }} or diff --git a/playbooks/functional/tests/rabbitmq.yaml b/playbooks/functional/tests/rabbitmq.yaml index 60e7ccd3..fbd5911b 100755 --- a/playbooks/functional/tests/rabbitmq.yaml +++ b/playbooks/functional/tests/rabbitmq.yaml @@ -25,7 +25,7 @@ command: kubectl get pods -l app.kubernetes.io/name=rabbitmq,app.kubernetes.io/instance=sample -o=jsonpath='{range .items[*]}{.status.podIP}{"\n"}{end}' register: _rabbitmq_ips until: _rabbitmq_ips is success - retries: 10 + retries: 60 delay: 5 failed_when: "{{ _rabbitmq_ips.stdout_lines | length == 0 }}"