From 254424d5ab0ff50f1ab4d5ce97b94b0f15bc1342 Mon Sep 17 00:00:00 2001 From: Marcelo Villa Date: Tue, 26 Mar 2024 15:27:46 -0500 Subject: [PATCH] Add middleware to prefix JupyterHub navbar items with /hub. --- .../kubernetes/services/jupyterhub/main.tf | 16 ++++++++++++++++ .../kubernetes/services/jupyterhub/middleware.tf | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/middleware.tf diff --git a/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/main.tf b/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/main.tf index f99ef62eed..c405f294be 100644 --- a/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/main.tf +++ b/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/main.tf @@ -231,6 +231,22 @@ resource "kubernetes_manifest" "jupyterhub" { port = 80 } ] + }, + { + kind = "Rule" + match = "Host(`${var.external-url}`) && (PathPrefix(`/home`) || PathPrefix(`/token`) || PathPrefix(`/admin`))" + middlewares = [ + { + name = kubernetes_manifest.jupyterhub-middleware-addprefix.manifest.metadata.name + namespace = var.namespace + } + ] + services = [ + { + name = "proxy-public" + port = 80 + } + ] } ] } diff --git a/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/middleware.tf b/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/middleware.tf new file mode 100644 index 0000000000..f09d0f3dfa --- /dev/null +++ b/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/middleware.tf @@ -0,0 +1,15 @@ +resource "kubernetes_manifest" "jupyterhub-middleware-addprefix" { + manifest = { + apiVersion = "traefik.containo.us/v1alpha1" + kind = "Middleware" + metadata = { + name = "nebari-jupyterhub-add-prefix" + namespace = var.namespace + } + spec = { + addPrefix = { + prefix = "/hub" + } + } + } +}