From 1204417d8962816cf6370f0c3bcee7f86c8cb94e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= <valtri@civ.zcu.cz>
Date: Mon, 17 Jun 2024 16:45:44 +0000
Subject: [PATCH] Testing instance: better to use redirect for the old
 notebooks URL

---
 testing/deployments/hub.yaml              |  1 +
 testing/inventory/99-all.yaml             |  2 +-
 testing/playbooks/notebooks-redirect.yaml | 53 +++++++++++++++++++++++
 3 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 testing/playbooks/notebooks-redirect.yaml

diff --git a/testing/deployments/hub.yaml b/testing/deployments/hub.yaml
index 3cb326c..9340778 100644
--- a/testing/deployments/hub.yaml
+++ b/testing/deployments/hub.yaml
@@ -13,6 +13,7 @@ ingress:
   tls:
     - hosts:
         - "{{ notebooks_hostname }}"
+        - "eosc-notebooks.vm.fedcloud.eu"
       secretName: acme-tls-hub
 
 singleuser:
diff --git a/testing/inventory/99-all.yaml b/testing/inventory/99-all.yaml
index f93b09e..beb9632 100644
--- a/testing/inventory/99-all.yaml
+++ b/testing/inventory/99-all.yaml
@@ -14,5 +14,5 @@ all:
     site_name: cesnet
     vault_mount_point: secrets/users/e1662e20-e34b-468c-b0ce-d899bc878364@egi.eu/eosc-testing
 
-    notebooks_hostname: eosc-notebooks.vm.fedcloud.eu
+    notebooks_hostname: notebooks-tst.cloud.cesnet.cz
     grafana_hostname: grafana-eosc-notebooks.vm.fedcloud.eu
diff --git a/testing/playbooks/notebooks-redirect.yaml b/testing/playbooks/notebooks-redirect.yaml
new file mode 100644
index 0000000..3253d21
--- /dev/null
+++ b/testing/playbooks/notebooks-redirect.yaml
@@ -0,0 +1,53 @@
+---
+- name: Notebooks redirect deployment
+  hosts: master
+  become: true
+  tasks:
+    - name: Deploy redirects
+      vars:
+        namespace: hub
+      shell: |-
+        kubectl apply -f - << EOF
+        ---
+        apiVersion: v1
+        kind: Service
+        metadata:
+          namespace: {{ namespace }}
+          name: redirect-old
+          labels:
+            app: redirect-old
+        spec:
+          ports:
+          - name: http
+            port: 80
+            protocol: TCP
+          selector:
+            app: redirect-old
+        ---
+        apiVersion: networking.k8s.io/v1
+        kind: Ingress
+        metadata:
+          annotations:
+            kubernetes.io/ingress.class: nginx
+            kubernetes.io/tls-acme: "true"
+            nginx.ingress.kubernetes.io/rewrite-target: https://{{ notebooks_hostname }}$1
+          name: redirect-old
+          namespace: {{ namespace }}
+        spec:
+          tls:
+            - hosts:
+              - eosc-notebooks.vm.fedcloud.eu
+              secretName: acme-tls-notebooks-old
+          rules:
+          - host: eosc-notebooks.vm.fedcloud.eu
+            http:
+              paths:
+              - backend:
+                  service:
+                    name: redirect-root
+                    port:
+                      name: http
+                path: /(.*)
+                pathType: Prefix
+        EOF
+      when: true
-- 
GitLab