From 20af451344aa7416f4287e5818d82551ebfc2f2d Mon Sep 17 00:00:00 2001 From: mamutmk5 <3045922+mamutmk5@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:16:14 +0200 Subject: [PATCH] BC-5546 - add Keda namespace activator for the ingresses --- .../templates/api-files-ingress.yml.j2 | 8 ++++++++ .../templates/api-fwu-ingress.yml.j2 | 8 ++++++++ .../roles/schulcloud-server-core/templates/ingress.yml.j2 | 8 ++++++++ .../templates/api-h5p-ingress.yml.j2 | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/ansible/roles/schulcloud-server-core/templates/api-files-ingress.yml.j2 b/ansible/roles/schulcloud-server-core/templates/api-files-ingress.yml.j2 index 79a856fb81b..41e4a301124 100644 --- a/ansible/roles/schulcloud-server-core/templates/api-files-ingress.yml.j2 +++ b/ansible/roles/schulcloud-server-core/templates/api-files-ingress.yml.j2 @@ -17,6 +17,14 @@ metadata: nginx.ingress.kubernetes.io/server-snippet: | client_header_buffer_size 100k; large_client_header_buffers 4 100k; +{% if KEDA_NAMESPACE_ACTIVATOR_ENABLED is defined %} + proxy_intercept_errors on; + error_page 503 = @errorpages; + + location @errorpages { + return 302 'https://activate.cd.dbildungscloud.dev/namespace?namespace={{ NAMESPACE }}&redirected-from-503=true'; + } +{% endif %} {% if CLUSTER_ISSUER is defined %} cert-manager.io/cluster-issuer: {{ CLUSTER_ISSUER }} {% endif %} diff --git a/ansible/roles/schulcloud-server-core/templates/api-fwu-ingress.yml.j2 b/ansible/roles/schulcloud-server-core/templates/api-fwu-ingress.yml.j2 index d1e32d4c4bd..411c365bdd8 100644 --- a/ansible/roles/schulcloud-server-core/templates/api-fwu-ingress.yml.j2 +++ b/ansible/roles/schulcloud-server-core/templates/api-fwu-ingress.yml.j2 @@ -17,6 +17,14 @@ metadata: nginx.ingress.kubernetes.io/server-snippet: | client_header_buffer_size 100k; large_client_header_buffers 4 100k; +{% if KEDA_NAMESPACE_ACTIVATOR_ENABLED is defined %} + proxy_intercept_errors on; + error_page 503 = @errorpages; + + location @errorpages { + return 302 'https://activate.cd.dbildungscloud.dev/namespace?namespace={{ NAMESPACE }}&redirected-from-503=true'; + } +{% endif %} {% if CLUSTER_ISSUER is defined %} cert-manager.io/cluster-issuer: {{ CLUSTER_ISSUER }} {% endif %} diff --git a/ansible/roles/schulcloud-server-core/templates/ingress.yml.j2 b/ansible/roles/schulcloud-server-core/templates/ingress.yml.j2 index 71f963b1caa..eb6951c3c92 100644 --- a/ansible/roles/schulcloud-server-core/templates/ingress.yml.j2 +++ b/ansible/roles/schulcloud-server-core/templates/ingress.yml.j2 @@ -17,6 +17,14 @@ metadata: nginx.ingress.kubernetes.io/server-snippet: | client_header_buffer_size 100k; large_client_header_buffers 4 100k; +{% if KEDA_NAMESPACE_ACTIVATOR_ENABLED is defined %} + proxy_intercept_errors on; + error_page 503 = @errorpages; + + location @errorpages { + return 302 'https://activate.cd.dbildungscloud.dev/namespace?namespace={{ NAMESPACE }}&redirected-from-503=true'; + } +{% endif %} {% if CLUSTER_ISSUER is defined %} cert-manager.io/cluster-issuer: {{ CLUSTER_ISSUER }} {% endif %} diff --git a/ansible/roles/schulcloud-server-h5p/templates/api-h5p-ingress.yml.j2 b/ansible/roles/schulcloud-server-h5p/templates/api-h5p-ingress.yml.j2 index b6118efc7ea..8b472c3e26d 100644 --- a/ansible/roles/schulcloud-server-h5p/templates/api-h5p-ingress.yml.j2 +++ b/ansible/roles/schulcloud-server-h5p/templates/api-h5p-ingress.yml.j2 @@ -17,6 +17,14 @@ metadata: nginx.ingress.kubernetes.io/server-snippet: | client_header_buffer_size 100k; large_client_header_buffers 4 100k; +{% if KEDA_NAMESPACE_ACTIVATOR_ENABLED is defined %} + proxy_intercept_errors on; + error_page 503 = @errorpages; + + location @errorpages { + return 302 'https://activate.cd.dbildungscloud.dev/namespace?namespace={{ NAMESPACE }}&redirected-from-503=true'; + } +{% endif %} {% if CLUSTER_ISSUER is defined %} cert-manager.io/cluster-issuer: {{ CLUSTER_ISSUER }} {% endif %}