From 19ac34607f0464e43f300ea59f4d00fba1585ea6 Mon Sep 17 00:00:00 2001 From: Nikita Churikov Date: Tue, 19 Nov 2024 14:26:22 +0100 Subject: [PATCH] Added info on how to setup the custom backend for the errors on k8s level Changed ingress configuration for the apps, so that they would redirect to our 503 page in case app not working Up apps charts versions --- README.md | 147 ++ apps/custom-app/Chart.yaml | 2 +- apps/custom-app/templates/ingress.yaml | 2 + apps/dash/Chart.yaml | 2 +- apps/dash/templates/ingress.yaml | 2 + apps/filemanager/Chart.yaml | 2 +- apps/filemanager/templates/ingress.yaml | 2 + apps/jupyter-lab/Chart.yaml | 2 +- apps/jupyter-lab/templates/ingress.yaml | 2 + apps/rstudio/Chart.yaml | 2 +- apps/rstudio/templates/ingress.yaml | 2 + apps/shiny/Chart.yaml | 2 +- apps/shiny/templates/ingress.yaml | 2 + apps/shinyproxy/Chart.yaml | 2 +- apps/shinyproxy/templates/ingress.yaml | 2 + apps/tissuumaps/Chart.yaml | 2 +- apps/tissuumaps/templates/ingress.yaml | 2 + apps/vscode/Chart.yaml | 2 +- apps/vscode/templates/ingress.yaml | 2 + error-page-404.html | 2955 +++++++++++++++++++++++ error-page-503.html | 2955 +++++++++++++++++++++++ 21 files changed, 6084 insertions(+), 9 deletions(-) create mode 100644 error-page-404.html create mode 100644 error-page-503.html diff --git a/README.md b/README.md index fc9c470..33042c1 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,153 @@ as these things will be provided by your cloud provider. But in case of a local deployment, navigate to the next section. +#### Setting up remote cluster + +##### Setting up custom error backend + +On remote environment each namespace should have a custom error backend setup for the nginx. +This is done by creating the following ConfigMaps and Services in the namespace: + +This only needs to be applied once per namespace. + +Configuration for the default backend: service and handling of a 404 error on a subdomain level (wild card domain). + +Create `custom-error-backent.yaml` file with the following content. +Don't forget to change the host name for the wildcard in case you are deploying the environment other than production. + +
+ Click to see the content of the custom-error-backend.yaml file + + ```yaml + --- + apiVersion: v1 + kind: Service + metadata: + name: nginx-errors + labels: + app.kubernetes.io/name: nginx-errors + app.kubernetes.io/part-of: ingress-nginx + spec: + selector: + app.kubernetes.io/name: nginx-errors + app.kubernetes.io/part-of: ingress-nginx + ports: + - port: 80 + targetPort: 8080 + name: http + --- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-errors + labels: + app.kubernetes.io/name: nginx-errors + app.kubernetes.io/part-of: ingress-nginx + spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: nginx-errors + app.kubernetes.io/part-of: ingress-nginx + template: + metadata: + labels: + app.kubernetes.io/name: nginx-errors + app.kubernetes.io/part-of: ingress-nginx + spec: + containers: + - name: nginx-error-server + # Update the image if there is a new version available + image: registry.k8s.io/ingress-nginx/custom-error-pages:v1.0.2@sha256:b2259cf6bfda813548a64bded551b1854cb600c4f095738b49b4c5cdf8ab9d21 + ports: + - containerPort: 8080 + # Mounting custom error page from ConfigMap 1 + volumeMounts: + - name: custom-error-pages-404 + mountPath: /www/404.html + subPath: 404.html + # Mounting custom error page from ConfigMap 2 + - name: custom-error-pages-503 + mountPath: /www/503.html + subPath: 503.html + + # Mounting volumes from two ConfigMaps + volumes: + - name: custom-error-pages-404 + configMap: + name: custom-error-pages-404 + items: + - key: "404" + path: "404.html" + - name: custom-error-pages-503 + configMap: + name: custom-error-pages-503 + items: + - key: "503" + path: "503.html" + --- + apiVersion: networking.k8s.io/v1 + kind: Ingress + metadata: + annotations: + nginx.ingress.kubernetes.io/custom-http-errors: 503,404 + nginx.ingress.kubernetes.io/default-backend: nginx-errors + name: wildcard-test-srv-dev + namespace: serve-dev + spec: + defaultBackend: + service: + name: nginx-errors + port: + number: 80 + rules: + # Change this if you are using a different domain + - host: '*.serve.scilifelab.se' + http: + paths: + - backend: + service: + name: nginx-errors + port: + number: 80 + path: /404.html + pathType: ImplementationSpecific + tls: + - hosts: + # Change this if you are using a different domain + - '*.serve.scilifelab.se' + secretName: prod-ingress + --- + # Custom error page configMap for the 404 error + apiVersion: v1 + kind: ConfigMap + metadata: + name: custom-error-pages-404 + data: + "404": "Error" + --- + # Custom error page configMap for the 503 error + apiVersion: v1 + kind: ConfigMap + metadata: + name: custom-error-pages-503 + data: + "503": "Error" + ``` +
+ +Apply the configuration to the namespace: +```bash +$ kubectl apply -f custom-error-backend.yaml +``` + +In the rancher dashboard change the values for configmaps `custom-error-pages-404` and `custom-error-pages-503` to +the following error pages. Don't forget to change the host names in the html pages. + +Take `404.html` file from [here](error-page-404.html) + +Take `503.html` file from [here](error-page-503.html) + #### Setup for local deployment If you are going to run this locally, you need to have a Kubernetes cluster running on your machine. diff --git a/apps/custom-app/Chart.yaml b/apps/custom-app/Chart.yaml index 5369ddc..50b1fbb 100644 --- a/apps/custom-app/Chart.yaml +++ b/apps/custom-app/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.1" description: A Helm chart for a standard serve app name: custom-app -version: 1.1.0 +version: 1.1.1 maintainers: - name: Team Whale email: serve@scilifelab.se diff --git a/apps/custom-app/templates/ingress.yaml b/apps/custom-app/templates/ingress.yaml index 1dc5e65..11b198c 100644 --- a/apps/custom-app/templates/ingress.yaml +++ b/apps/custom-app/templates/ingress.yaml @@ -10,6 +10,8 @@ metadata: nginx.ingress.kubernetes.io/auth-url: "{{ .Values.global.protocol }}://{{ .Values.global.auth_domain }}:8080/auth/?release={{ .Values.release }}" nginx.ingress.kubernetes.io/auth-signin: "https://{{ .Values.global.domain }}/accounts/login/?next=$scheme%3A%2F%2F$host" {{- end }} + nginx.ingress.kubernetes.io/custom-http-errors: "503" + nginx.ingress.kubernetes.io/default-backend: nginx-errors spec: rules: - host: {{ .Release.Name }}.{{ .Values.global.domain }} diff --git a/apps/dash/Chart.yaml b/apps/dash/Chart.yaml index e5f6cc9..e503483 100644 --- a/apps/dash/Chart.yaml +++ b/apps/dash/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.1" description: A Helm chart Dash apps name: dash-app -version: 1.0.2 +version: 1.0.3 maintainers: - name: Team Whale email: serve@scilifelab.se diff --git a/apps/dash/templates/ingress.yaml b/apps/dash/templates/ingress.yaml index 1dc5e65..11b198c 100644 --- a/apps/dash/templates/ingress.yaml +++ b/apps/dash/templates/ingress.yaml @@ -10,6 +10,8 @@ metadata: nginx.ingress.kubernetes.io/auth-url: "{{ .Values.global.protocol }}://{{ .Values.global.auth_domain }}:8080/auth/?release={{ .Values.release }}" nginx.ingress.kubernetes.io/auth-signin: "https://{{ .Values.global.domain }}/accounts/login/?next=$scheme%3A%2F%2F$host" {{- end }} + nginx.ingress.kubernetes.io/custom-http-errors: "503" + nginx.ingress.kubernetes.io/default-backend: nginx-errors spec: rules: - host: {{ .Release.Name }}.{{ .Values.global.domain }} diff --git a/apps/filemanager/Chart.yaml b/apps/filemanager/Chart.yaml index e2c5992..aa948dc 100644 --- a/apps/filemanager/Chart.yaml +++ b/apps/filemanager/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.1" description: A Helm chart for the serve File Manager name: filemanager -version: 1.0.2 +version: 1.0.3 maintainers: - name: Team Whale email: serve@scilifelab.se diff --git a/apps/filemanager/templates/ingress.yaml b/apps/filemanager/templates/ingress.yaml index 61aebbf..811313f 100644 --- a/apps/filemanager/templates/ingress.yaml +++ b/apps/filemanager/templates/ingress.yaml @@ -7,6 +7,8 @@ metadata: nginx.ingress.kubernetes.io/auth-url: "{{ .Values.global.protocol }}://{{ .Values.global.auth_domain }}:8080/auth/?release={{ .Values.release }}" nginx.ingress.kubernetes.io/auth-signin: "https://{{ .Values.global.domain }}/accounts/login/?next=$scheme%3A%2F%2F$host" {{- end }} + nginx.ingress.kubernetes.io/custom-http-errors: "503" + nginx.ingress.kubernetes.io/default-backend: nginx-errors name: {{ .Release.Name }}-filemanager-ingress namespace: {{ .Release.Namespace }} spec: diff --git a/apps/jupyter-lab/Chart.yaml b/apps/jupyter-lab/Chart.yaml index d42f98f..04f0173 100644 --- a/apps/jupyter-lab/Chart.yaml +++ b/apps/jupyter-lab/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.1" description: A Helm chart for Jupyter Lab name: lab -version: 1.0.2 +version: 1.0.3 maintainers: - name: Team Whale email: serve@scilifelab.se diff --git a/apps/jupyter-lab/templates/ingress.yaml b/apps/jupyter-lab/templates/ingress.yaml index e3f1834..9d0b51b 100644 --- a/apps/jupyter-lab/templates/ingress.yaml +++ b/apps/jupyter-lab/templates/ingress.yaml @@ -11,6 +11,8 @@ metadata: nginx.ingress.kubernetes.io/auth-url: "{{ .Values.global.protocol }}://{{ .Values.global.auth_domain }}:8080/auth/?release={{ .Values.release }}" nginx.ingress.kubernetes.io/auth-signin: "https://{{ .Values.global.domain }}/accounts/login/?next=$scheme%3A%2F%2F$host" #nginx.ingress.kubernetes.io/auth-response-headers: X-Forwarded-Host + nginx.ingress.kubernetes.io/custom-http-errors: "503" + nginx.ingress.kubernetes.io/default-backend: nginx-errors spec: rules: - host: {{ .Release.Name }}.{{ .Values.global.domain }} diff --git a/apps/rstudio/Chart.yaml b/apps/rstudio/Chart.yaml index 0d60ccf..f1d9d5f 100644 --- a/apps/rstudio/Chart.yaml +++ b/apps/rstudio/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.1" description: A Helm chart for RStudio in the browser name: rstudio -version: 1.0.2 +version: 1.0.3 maintainers: - name: Team Whale email: serve@scilifelab.se diff --git a/apps/rstudio/templates/ingress.yaml b/apps/rstudio/templates/ingress.yaml index a1d01bf..a28a494 100644 --- a/apps/rstudio/templates/ingress.yaml +++ b/apps/rstudio/templates/ingress.yaml @@ -10,6 +10,8 @@ metadata: nginx.ingress.kubernetes.io/auth-url: "{{ .Values.global.protocol }}://{{ .Values.global.auth_domain }}:8080/auth/?release={{ .Values.release }}" nginx.ingress.kubernetes.io/auth-signin: "https://{{ .Values.global.domain }}/accounts/login/?next=$scheme%3A%2F%2F$host" #nginx.ingress.kubernetes.io/auth-response-headers: X-Forwarded-Host + nginx.ingress.kubernetes.io/custom-http-errors: "503" + nginx.ingress.kubernetes.io/default-backend: nginx-errors spec: rules: - host: {{ .Release.Name }}.{{ .Values.global.domain }} diff --git a/apps/shiny/Chart.yaml b/apps/shiny/Chart.yaml index 2ae8cd0..7f4c1c0 100644 --- a/apps/shiny/Chart.yaml +++ b/apps/shiny/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.1" description: A Helm chart Shiny apps name: shinyapp -version: 1.0.3 +version: 1.0.4 maintainers: - name: Team Whale email: serve@scilifelab.se diff --git a/apps/shiny/templates/ingress.yaml b/apps/shiny/templates/ingress.yaml index 1dc5e65..11b198c 100644 --- a/apps/shiny/templates/ingress.yaml +++ b/apps/shiny/templates/ingress.yaml @@ -10,6 +10,8 @@ metadata: nginx.ingress.kubernetes.io/auth-url: "{{ .Values.global.protocol }}://{{ .Values.global.auth_domain }}:8080/auth/?release={{ .Values.release }}" nginx.ingress.kubernetes.io/auth-signin: "https://{{ .Values.global.domain }}/accounts/login/?next=$scheme%3A%2F%2F$host" {{- end }} + nginx.ingress.kubernetes.io/custom-http-errors: "503" + nginx.ingress.kubernetes.io/default-backend: nginx-errors spec: rules: - host: {{ .Release.Name }}.{{ .Values.global.domain }} diff --git a/apps/shinyproxy/Chart.yaml b/apps/shinyproxy/Chart.yaml index 1f70ded..b3f5128 100644 --- a/apps/shinyproxy/Chart.yaml +++ b/apps/shinyproxy/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: shinyproxy description: A Helm chart to install Shinyproxy type: application -version: 1.4.2 +version: 1.4.3 appVersion: "0.1" maintainers: - name: Team Whale diff --git a/apps/shinyproxy/templates/ingress.yaml b/apps/shinyproxy/templates/ingress.yaml index 90f1501..efe9be7 100644 --- a/apps/shinyproxy/templates/ingress.yaml +++ b/apps/shinyproxy/templates/ingress.yaml @@ -12,6 +12,8 @@ metadata: {{- end }} nginx.ingress.kubernetes.io/proxy-body-size: 2000m #nginx.ingress.kubernetes.io/auth-response-headers: X-Forwarded-Host + nginx.ingress.kubernetes.io/custom-http-errors: "503" + nginx.ingress.kubernetes.io/default-backend: nginx-errors spec: rules: - host: {{ .Release.Name }}.{{ .Values.global.domain }} diff --git a/apps/tissuumaps/Chart.yaml b/apps/tissuumaps/Chart.yaml index 6e19554..7d0eb1a 100644 --- a/apps/tissuumaps/Chart.yaml +++ b/apps/tissuumaps/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.1" description: A Helm chart tissuumaps apps name: tissuumaps -version: 1.0.2 +version: 1.0.3 maintainers: - name: Team Whale email: serve@scilifelab.se diff --git a/apps/tissuumaps/templates/ingress.yaml b/apps/tissuumaps/templates/ingress.yaml index 1dc5e65..11b198c 100644 --- a/apps/tissuumaps/templates/ingress.yaml +++ b/apps/tissuumaps/templates/ingress.yaml @@ -10,6 +10,8 @@ metadata: nginx.ingress.kubernetes.io/auth-url: "{{ .Values.global.protocol }}://{{ .Values.global.auth_domain }}:8080/auth/?release={{ .Values.release }}" nginx.ingress.kubernetes.io/auth-signin: "https://{{ .Values.global.domain }}/accounts/login/?next=$scheme%3A%2F%2F$host" {{- end }} + nginx.ingress.kubernetes.io/custom-http-errors: "503" + nginx.ingress.kubernetes.io/default-backend: nginx-errors spec: rules: - host: {{ .Release.Name }}.{{ .Values.global.domain }} diff --git a/apps/vscode/Chart.yaml b/apps/vscode/Chart.yaml index 480e954..5950593 100644 --- a/apps/vscode/Chart.yaml +++ b/apps/vscode/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v1 appVersion: "0.1" description: A Helm chart for VS code in the browser name: vscode -version: 1.0.1 +version: 1.0.2 maintainers: - name: Team Whale email: serve@scilifelab.se diff --git a/apps/vscode/templates/ingress.yaml b/apps/vscode/templates/ingress.yaml index a1d01bf..a28a494 100644 --- a/apps/vscode/templates/ingress.yaml +++ b/apps/vscode/templates/ingress.yaml @@ -10,6 +10,8 @@ metadata: nginx.ingress.kubernetes.io/auth-url: "{{ .Values.global.protocol }}://{{ .Values.global.auth_domain }}:8080/auth/?release={{ .Values.release }}" nginx.ingress.kubernetes.io/auth-signin: "https://{{ .Values.global.domain }}/accounts/login/?next=$scheme%3A%2F%2F$host" #nginx.ingress.kubernetes.io/auth-response-headers: X-Forwarded-Host + nginx.ingress.kubernetes.io/custom-http-errors: "503" + nginx.ingress.kubernetes.io/default-backend: nginx-errors spec: rules: - host: {{ .Release.Name }}.{{ .Values.global.domain }} diff --git a/error-page-404.html b/error-page-404.html new file mode 100644 index 0000000..3feb67b --- /dev/null +++ b/error-page-404.html @@ -0,0 +1,2955 @@ + + + + Not found | SciLifeLab Serve (beta) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

Page cannot be served 🥁 (404 error)

+

It's okay, don't worry. Just go to the home page + and try what you wanted to do again.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/error-page-503.html b/error-page-503.html new file mode 100644 index 0000000..8c46285 --- /dev/null +++ b/error-page-503.html @@ -0,0 +1,2955 @@ + + + + Temporary not available | SciLifeLab Serve (beta) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

Service is temporary unavailable (503 error)

+

The application is being created, please wait ☕️.

+

Try to refresh page a few times or if it takes too long return to the previous page.

+

If the problem persists please contact us via serve@scilifelab.se and describe the issue. +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +