From d3b07a5f6dd5d7339b4b8e1311b6e2fe92a9f433 Mon Sep 17 00:00:00 2001 From: Nikita Churikov <8545082+churnikov@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:49:42 +0200 Subject: [PATCH 01/10] SS-1029 running serve in rancher desktop (#41) Co-authored-by: Hamza --- README.md | 317 +++++++++++++++++- apps/custom-app/templates/deployment.yaml | 4 - apps/custom-app/values.yaml | 3 - apps/dash/templates/deployment.yaml | 4 - apps/dash/values.yaml | 3 - apps/jupyter-lab/templates/deployment.yaml | 4 - apps/jupyter-lab/values.yaml | 3 - apps/mlflow/chart/values.yaml | 3 - .../chart/templates/deployment.yaml | 4 - apps/python-serve/chart/values.yaml | 3 - apps/pytorch-serve/chart/values.yaml | 3 - apps/rstudio/templates/deployment.yaml | 4 - apps/rstudio/values.yaml | 3 - apps/shiny/templates/deployment.yaml | 4 - apps/shiny/values.yaml | 3 - apps/tensorflow-serve/chart/values.yaml | 3 - apps/tissuumaps/templates/deployment.yaml | 4 - apps/tissuumaps/values.yaml | 3 - apps/volumek8s/values.yaml | 6 + apps/vscode/templates/deployment.yaml | 4 - apps/vscode/values.yaml | 3 - serve/templates/celery-beat-deployment.yaml | 2 - serve/templates/celery-flower-deployment.yaml | 2 - serve/templates/celery-worker-deployment.yaml | 2 - .../templates/event-listener-deployment.yaml | 2 - serve/templates/media-vol.yaml | 2 +- serve/templates/nginx-deployment.yaml | 2 - serve/templates/studio-deployment.yaml | 22 +- serve/templates/studio-service.yaml | 5 + .../templates/studio-settings-configmap.yaml | 8 +- serve/values.yaml | 55 ++- 31 files changed, 364 insertions(+), 126 deletions(-) diff --git a/README.md b/README.md index dd4fe7d..fc9c470 100644 --- a/README.md +++ b/README.md @@ -9,30 +9,321 @@ This repository contains Helm charts for SciLifeLab Serve. If you are using SciLifeLab Serve and notice a bug or if there is a feature you would like to be added feel free to [create an issue](https://github.com/ScilifelabDataCentre/serve/issues/new/choose) with a bug report or feature request. ## How to deploy + +### Prerequisites + +- A Kubernetes cluster version **1.28.6** +- Helm 3 +- A storage class for dynamic provisioning of persistent volumes + +If you are going to run this on a remote cluster, then you probably don't need to think about this +as these things will be provided by your cloud provider. + +But in case of a local deployment, navigate to the next section. + +#### Setup for local deployment + +If you are going to run this locally, you need to have a Kubernetes cluster running on your machine. +You can use [Rancher Desktop](https://rancherdesktop.io/) for this purpose. + +Follow their instruction to install Rancher Desktop, and then start it. + +Recommended settings for Rancher Desktop: +- `Preferences > Kubernetes` select kubernetes version `1.28.6`. +- `Preferences > Container Engine` select `containerd` as the container engine. +- `Preferences > Virtual Machine > Emulation` select `QEMU` + - If you are running on an M3 Mac select `VZ` +- `Preferences > Virtual Machine > Hardware` select `4 CPUs` and `16 GB` of memory. + +##### Serve image + +By default, the image is pulled from the public registry. This image is the one we are using in production. +So you don't need to build the image yourself if you want to just try it out locally. + +But if you want to develop, you need to build the image yourself. + +**Building image for Rancher Desktop** + +Rancher Desktop brings a number of tools when you install it. +One of them is `nerdctl` which is a drop-in replacement for `docker` and `docker-compose`. + +Rancher Desktop also brings a local registry that you can use to push images to. +And this registry can be accessed from your Kubernetes cluster and used as if you were using docker. + +See [Serve](https://github.com/ScilifelabDataCentre/serve/) repository for up-to-date instructions on +how to build the image for local development. + +But this setup expects that you have an image tagged `mystudio` built using `nerdctl` and pushed to the `k8s.io` namespace. + +### Deploying + +> Using the following you'll make sure that your Rancher Desktop installation is working as expected using the default settings. +> These instructions are almost the same as the ones you would use for a remote cluster except for the storage class. +> If it doesn't work you should debug your installation and contact team members for help. + +**Outcomes of this section** +- You'll prepare your environment for the proper local deployment of Serve; +- Running instance of Serve on your local machine available on [http://studio.127.0.0.1.nip.io/](http://studio.127.0.0.1.nip.io/). + + + First, clone this repository + +```bash +$ git clone https://github.com/ScilifelabDataCentre/serve-charts.git +``` + +Then navigate to the `serve-charts/serve` folder + +```bash +$ cd serve-charts/serve ``` -git clone https://github.com/ScilifelabDataCentre/serve-charts.git + +Now you need to create an override file for the `values.yaml` file. + +Create a file called `values-local.yaml` and add the following content: + +```yaml filename="values-local.yaml" +# https://helm.sh/docs/chart_template_guide/yaml_techniques/#yaml-anchors +# for local development +storageClass: &storage_class local-path +#storage access mode +access_mode: &access_mode ReadWriteOnce +accessmode: *access_mode + +global: + studio: + superuserPassword: "Test@12345" + superuserEmail: "admin@sll.se" + storageClass: *storage_class + postgresql: + storageClass: *storage_class + +studio: + # Only locally on a debug environment + debug: true + storage: + storageClass: *storage_class + media: + storage: + storageClass: *storage_class + accessModes: *access_mode + +postgresql: + primary: + persistence: + storageClass: *storage_class + accessModes: + - *access_mode ``` -Then navigate to the `serve-charts/serve` folder, and run +This is necessary because the default values are set for a production environment. Specifically, the storage class +has to change because the default storage class is not available in a Rancher Desktop environment. +```bash +$ helm dependency update +# The following command will install the chart with the values from values.yaml and values-local.yaml +# values-local.yaml will override the values from values.yaml +$ helm install serve . -f values.yaml -f values-local.yaml ``` -helm dependency update -helm install serve . + +As a result you should have a running instance of Serve on your local machine available on [http://studio.127.0.0.1.nip.io/](http://studio.127.0.0.1.nip.io/). + +#### Swapping default docker image with the one built locally + +
+ TJ;DR Just commands + + ```bash + $ git clone https://github.com/ScilifelabDataCentre/serve-charts.git + $ cd serve-charts/serve + $ cat < values-local.yaml +environment: "local" +# Path will be mounted using rancher desktop to the /app path in the container +source_code_path: "/Users/nikch187/Projects/sll/serve" +# https://helm.sh/docs/chart_template_guide/yaml_techniques/#yaml-anchors +# for local development +storageClass: &storage_class local-path +#storage access mode +access_mode: &access_mode ReadWriteOnce +accessmode: *access_mode + +global: + studio: + superuserPassword: "Test@12345" + superuserEmail: "admin@sll.se" + storageClass: *storage_class + postgresql: + storageClass: *storage_class + +studio: + # Only locally on a debug environment + debug: true + storage: + storageClass: *storage_class + media: + storage: + storageClass: *storage_class + accessModes: *access_mode + + # We use pull policy Never because see the following link: + # https://github.com/rancher-sandbox/rancher-desktop/issues/952#issuecomment-993135128 + static: + image: mystudio + pullPolicy: Never + + image: + repository: mystudio + pullPolicy: Never + + securityContext: + # Disables security context for local development + # Essentially allow the container to run as root + enabled: false + + readinessProbe: + enabled: false + + livenessProbe: + enabled: false + +postgresql: + primary: + persistence: + storageClass: *storage_class + accessModes: + - *access_mode + EOF + $ helm upgrade serve . -f values.yaml -f values-local.yaml + ``` +
+ +**Outcomes of this section:** +- Instead of a Django server, you'll have an ssh server running for the [PyCharm setup](https://github.com/ScilifelabDataCentre/serve/?tab=readme-ov-file#deploy-serve-for-local-development-with-rancher-desktop) +- You'll have a host machine's folder with the [Serve](https://github.com/ScilifelabDataCentre/serve/) code mounted to the container; + +Now that everything is running, you can swap the default image with the one you built locally. + +> See the [Serve image section](https://github.com/ScilifelabDataCentre/serve/?tab=readme-ov-file#deploy-serve-for-local-development-with-rancher-desktop) for instructions on how to build the image. + +Go back to the `values-local.yaml` file update it with the following content: + +```yaml filename="values-local.yaml" +environment: "local" + +# Path will be mounted using rancher desktop to the /app path in the container +source_code_path: "/absolute/path/to/your/serve" +# https://helm.sh/docs/chart_template_guide/yaml_techniques/#yaml-anchors +# ... +studio: + # Append the following to the end of the studio section + + # We use pull policy Never because see the following link: + # https://github.com/rancher-sandbox/rancher-desktop/issues/952#issuecomment-993135128 + static: + image: mystudio + pullPolicy: Never + + image: + repository: mystudio + pullPolicy: Never + + securityContext: + # Disables security context for local development + # Essentially allow the container to run as root + enabled: false + + readinessProbe: + enabled: false + + livenessProbe: + enabled: false ``` -Depending on your storageclass, you might have to set this aswell. -For instance, if you use `microk8s`, them you run +
+ Full content of the values-local.yaml file + +```yaml + environment: "local" + # Path will be mounted using rancher desktop to the /app path in the container + source_code_path: "/Users/nikch187/Projects/sll/serve" + # https://helm.sh/docs/chart_template_guide/yaml_techniques/#yaml-anchors + # for local development + storageClass: &storage_class local-path + #storage access mode + access_mode: &access_mode ReadWriteOnce + accessmode: *access_mode + + global: + studio: + superuserPassword: "Test@12345" + superuserEmail: "admin@sll.se" + storageClass: *storage_class + postgresql: + storageClass: *storage_class + + studio: + # Only locally on a debug environment + debug: true + storage: + storageClass: *storage_class + media: + storage: + storageClass: *storage_class + accessModes: *access_mode + + # We use pull policy Never because see the following link: + # https://github.com/rancher-sandbox/rancher-desktop/issues/952#issuecomment-993135128 + static: + image: mystudio + pullPolicy: Never + + image: + repository: mystudio + pullPolicy: Never + + securityContext: + # Disables security context for local development + # Essentially allow the container to run as root + enabled: false + + readinessProbe: + enabled: false + + livenessProbe: + enabled: false + + postgresql: + primary: + persistence: + storageClass: *storage_class + accessModes: + - *access_mode + ``` + +
+ +After doing this run the following command to upgrade the deployment: +```bash +helm upgrade serve . -f values.yaml -f values-local.yaml ``` -helm install --set global.postgresql.storageClass=microk8s-hostpath serve . + +Now you can proceed to [set up PyCharm](https://github.com/ScilifelabDataCentre/serve?tab=readme-ov-file#pycharm-setup) + +If you don't want to set up PyCharm, you can just run Django from the container. + +```bash +$ kubectl get po +# Get the name of the studio pod +$ kubectl exec -it -- /bin/bash +# Now you are inside the container +$ sh scripts/run_web.sh ``` -All resources will by default be created in the default namespace. -Serve will be avaliable at https://studio.127.0.0.1.nip.io -Obs that you might have to make changes to your particular ingress controller (nginx is supported in this chart) to connect to the URL. -If the ingress does not work for any reason, you can try to port-forward the studio service port to your localhost. +Please note, that the folder you are in, `/app`, is the folder where the code is mounted. +It means that you can make changes to the code on your host machine and see the changes in the container. ## Deploy an SSL certificate @@ -84,10 +375,10 @@ studio: inactive_users: false #Users that sign-up can be inactive by default if desired csrf_trusted_origins: "https://studio.127.0.0.1.nip.io:8082" #extra trusted origin for django server, for example if you port-forward to port 8082 image: # using a local image registry with hostname k3d-registry - repository: k3d-registry:35187/stackn:develop #This image can be built from Dockerfile (https://github.com/scaleoutsystems/stackn) + repository: k3d-registry:35187/serve:develop #This image can be built from Dockerfile (https://github.com/scaleoutsystems/serve) pullPolicy: Always # used to ensure that each time we redeploy always pull the latest image static: - image: k3d-registry:35187/stackn-nginx:develop #This image can be built from Dockerfile.nginx (https://github.com/scaleoutsystems/stackn) + image: k3d-registry:35187/serve-nginx:develop #This image can be built from Dockerfile.nginx (https://github.com/scaleoutsystems/serve) media: storage: accessModes: ReadWriteOnce diff --git a/apps/custom-app/templates/deployment.yaml b/apps/custom-app/templates/deployment.yaml index 95723ad..83b1e55 100644 --- a/apps/custom-app/templates/deployment.yaml +++ b/apps/custom-app/templates/deployment.yaml @@ -28,10 +28,6 @@ spec: type: app pod: {{ .Values.appname }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} automountServiceAccountToken: false securityContext: seccompProfile: diff --git a/apps/custom-app/values.yaml b/apps/custom-app/values.yaml index a3879e2..af6c814 100644 --- a/apps/custom-app/values.yaml +++ b/apps/custom-app/values.yaml @@ -22,9 +22,6 @@ service: name: customapp-svc port: 80 -imagePullSecrets: - - name: regcred - ingress: secretName: prod-ingress diff --git a/apps/dash/templates/deployment.yaml b/apps/dash/templates/deployment.yaml index 5f71b08..beda770 100644 --- a/apps/dash/templates/deployment.yaml +++ b/apps/dash/templates/deployment.yaml @@ -28,10 +28,6 @@ spec: type: app pod: {{ .Values.appname }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} automountServiceAccountToken: false securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} diff --git a/apps/dash/values.yaml b/apps/dash/values.yaml index e89640f..ffba171 100644 --- a/apps/dash/values.yaml +++ b/apps/dash/values.yaml @@ -18,9 +18,6 @@ service: name: dashapp-svc port: 80 -imagePullSecrets: - - name: regcred - ingress: secretName: prod-ingress diff --git a/apps/jupyter-lab/templates/deployment.yaml b/apps/jupyter-lab/templates/deployment.yaml index 16c308a..bacfc35 100644 --- a/apps/jupyter-lab/templates/deployment.yaml +++ b/apps/jupyter-lab/templates/deployment.yaml @@ -81,10 +81,6 @@ spec: - name: {{ $key }} mountPath: /home/jovyan/work/{{ $key }} {{- end }} - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} terminationGracePeriodSeconds: 30 dnsPolicy: ClusterFirst volumes: diff --git a/apps/jupyter-lab/values.yaml b/apps/jupyter-lab/values.yaml index 33a3527..aaf7fdf 100644 --- a/apps/jupyter-lab/values.yaml +++ b/apps/jupyter-lab/values.yaml @@ -19,9 +19,6 @@ global: apps: volumek8s: -imagePullSecrets: - - name: regcred - minio: access_key: minio secret_key: minio123 diff --git a/apps/mlflow/chart/values.yaml b/apps/mlflow/chart/values.yaml index 97fad01..a8a2e45 100644 --- a/apps/mlflow/chart/values.yaml +++ b/apps/mlflow/chart/values.yaml @@ -22,9 +22,6 @@ s3: service: port: -imagePullSecrets: - - name: regcred - ingress: v1beta1: false secretName: prod-ingress diff --git a/apps/python-serve/chart/templates/deployment.yaml b/apps/python-serve/chart/templates/deployment.yaml index f35e023..33871ff 100644 --- a/apps/python-serve/chart/templates/deployment.yaml +++ b/apps/python-serve/chart/templates/deployment.yaml @@ -27,10 +27,6 @@ spec: type: app pod: {{ .Values.appname }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} automountServiceAccountToken: false securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} diff --git a/apps/python-serve/chart/values.yaml b/apps/python-serve/chart/values.yaml index fbabd29..b7fe70f 100644 --- a/apps/python-serve/chart/values.yaml +++ b/apps/python-serve/chart/values.yaml @@ -16,9 +16,6 @@ appconfig: service: name: pythonserve-svc -imagePullSecrets: - - name: regcred - ingress: secretName: prod-ingress diff --git a/apps/pytorch-serve/chart/values.yaml b/apps/pytorch-serve/chart/values.yaml index 033bdfc..b42757b 100644 --- a/apps/pytorch-serve/chart/values.yaml +++ b/apps/pytorch-serve/chart/values.yaml @@ -42,9 +42,6 @@ model_card: enabled: false path: model-card -imagePullSecrets: - - name: regcred - ingress: podSecurityContext: diff --git a/apps/rstudio/templates/deployment.yaml b/apps/rstudio/templates/deployment.yaml index 6b09467..ba96e87 100644 --- a/apps/rstudio/templates/deployment.yaml +++ b/apps/rstudio/templates/deployment.yaml @@ -28,10 +28,6 @@ spec: type: app pod: {{ .Values.appname }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} automountServiceAccountToken: false securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} diff --git a/apps/rstudio/values.yaml b/apps/rstudio/values.yaml index e3beb34..7e58bbb 100644 --- a/apps/rstudio/values.yaml +++ b/apps/rstudio/values.yaml @@ -19,9 +19,6 @@ service: name: rstudio-svc port: 80 -imagePullSecrets: - - name: regcred - ingress: v1beta1: false secretName: prod-ingress diff --git a/apps/shiny/templates/deployment.yaml b/apps/shiny/templates/deployment.yaml index 9357339..19f7214 100644 --- a/apps/shiny/templates/deployment.yaml +++ b/apps/shiny/templates/deployment.yaml @@ -28,10 +28,6 @@ spec: type: app pod: {{ .Values.appname }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} automountServiceAccountToken: false securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} diff --git a/apps/shiny/values.yaml b/apps/shiny/values.yaml index 49a507c..7edac64 100644 --- a/apps/shiny/values.yaml +++ b/apps/shiny/values.yaml @@ -19,9 +19,6 @@ service: name: shiny-svc port: 80 -imagePullSecrets: - - name: regcred - ingress: secretName: prod-ingress diff --git a/apps/tensorflow-serve/chart/values.yaml b/apps/tensorflow-serve/chart/values.yaml index 87fb906..a8cdf5b 100644 --- a/apps/tensorflow-serve/chart/values.yaml +++ b/apps/tensorflow-serve/chart/values.yaml @@ -40,9 +40,6 @@ model_card: enabled: false path: model-card -imagePullSecrets: - - name: regcred - ingress: podSecurityContext: diff --git a/apps/tissuumaps/templates/deployment.yaml b/apps/tissuumaps/templates/deployment.yaml index 1f0f5a7..a458df0 100644 --- a/apps/tissuumaps/templates/deployment.yaml +++ b/apps/tissuumaps/templates/deployment.yaml @@ -28,10 +28,6 @@ spec: type: app pod: {{ .Values.appname }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} automountServiceAccountToken: false securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} diff --git a/apps/tissuumaps/values.yaml b/apps/tissuumaps/values.yaml index d84c914..1229e3e 100644 --- a/apps/tissuumaps/values.yaml +++ b/apps/tissuumaps/values.yaml @@ -21,9 +21,6 @@ service: targetport: 80 port: 80 -imagePullSecrets: - - name: regcred - ingress: secretName: prod-ingress diff --git a/apps/volumek8s/values.yaml b/apps/volumek8s/values.yaml index c29e83d..3474e0c 100644 --- a/apps/volumek8s/values.yaml +++ b/apps/volumek8s/values.yaml @@ -1,3 +1,6 @@ +# locally +# accessModes: ReadWriteOnce +# remote accessModes: ReadWriteMany storageClass: default @@ -9,4 +12,7 @@ project: volume: size: 10Mi storageClass: false +# locally +# accessModes: ReadWriteOnce +# remote accessModes: ReadWriteMany diff --git a/apps/vscode/templates/deployment.yaml b/apps/vscode/templates/deployment.yaml index 6d1d85e..5aa9adc 100644 --- a/apps/vscode/templates/deployment.yaml +++ b/apps/vscode/templates/deployment.yaml @@ -32,10 +32,6 @@ spec: affinity: {{ .Values.affinity | toYaml | nindent 8 | trim }} {{ end }} - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} automountServiceAccountToken: false securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} diff --git a/apps/vscode/values.yaml b/apps/vscode/values.yaml index ba8e539..8dc9297 100644 --- a/apps/vscode/values.yaml +++ b/apps/vscode/values.yaml @@ -30,9 +30,6 @@ service: port: 80 targetport: 8080 -imagePullSecrets: - - name: regcred - ingress: v1beta1: false secretName: prod-ingress diff --git a/serve/templates/celery-beat-deployment.yaml b/serve/templates/celery-beat-deployment.yaml index 71ce6d4..dba1638 100644 --- a/serve/templates/celery-beat-deployment.yaml +++ b/serve/templates/celery-beat-deployment.yaml @@ -121,8 +121,6 @@ spec: - mountPath: /app/studio/settings.py subPath: settings.py name: {{ .Release.Name}}-settings-configmap - imagePullSecrets: - - name: ghcrsecret restartPolicy: Always volumes: - name: {{ .Release.Name}}-settings-configmap diff --git a/serve/templates/celery-flower-deployment.yaml b/serve/templates/celery-flower-deployment.yaml index a6e7089..d77a4fe 100644 --- a/serve/templates/celery-flower-deployment.yaml +++ b/serve/templates/celery-flower-deployment.yaml @@ -103,8 +103,6 @@ spec: - mountPath: /app/studio/settings.py subPath: settings.py name: {{ .Release.Name}}-settings-configmap - imagePullSecrets: - - name: ghcrsecret restartPolicy: Always volumes: {{- if .Values.chartcontroller.addSecret }} diff --git a/serve/templates/celery-worker-deployment.yaml b/serve/templates/celery-worker-deployment.yaml index 1a8e735..bd9e8a7 100644 --- a/serve/templates/celery-worker-deployment.yaml +++ b/serve/templates/celery-worker-deployment.yaml @@ -127,8 +127,6 @@ spec: - mountPath: /app/studio/settings.py subPath: settings.py name: {{ .Release.Name}}-settings-configmap - imagePullSecrets: - - name: ghcrsecret restartPolicy: Always volumes: {{- if .Values.chartcontroller.addSecret }} diff --git a/serve/templates/event-listener-deployment.yaml b/serve/templates/event-listener-deployment.yaml index 62fc082..5939dee 100644 --- a/serve/templates/event-listener-deployment.yaml +++ b/serve/templates/event-listener-deployment.yaml @@ -71,8 +71,6 @@ spec: requests: cpu: {{ .Values.eventListener.resources.requests.cpu }} memory: {{ .Values.eventListener.resources.requests.memory }} - imagePullSecrets: - - name: ghcrsecret restartPolicy: Always volumes: status: {} diff --git a/serve/templates/media-vol.yaml b/serve/templates/media-vol.yaml index f39274f..c541a4e 100644 --- a/serve/templates/media-vol.yaml +++ b/serve/templates/media-vol.yaml @@ -6,7 +6,7 @@ metadata: "helm.sh/resource-policy": keep spec: accessModes: - - {{ .Values.studio.media.storage.accessModes | default "ReadWriteMany"}} + - {{ .Values.studio.media.storage.accessModes }} storageClassName: {{ include "stackn.studio.media.storageclass" . }} resources: requests: diff --git a/serve/templates/nginx-deployment.yaml b/serve/templates/nginx-deployment.yaml index 3e25624..5eef53b 100644 --- a/serve/templates/nginx-deployment.yaml +++ b/serve/templates/nginx-deployment.yaml @@ -60,6 +60,4 @@ spec: requests: cpu: {{ .Values.studio.static.resources.requests.cpu }} memory: {{ .Values.studio.static.resources.requests.memory }} - imagePullSecrets: - - name: ghcrsecret diff --git a/serve/templates/studio-deployment.yaml b/serve/templates/studio-deployment.yaml index 73dcaa9..e8eda3e 100644 --- a/serve/templates/studio-deployment.yaml +++ b/serve/templates/studio-deployment.yaml @@ -54,9 +54,17 @@ spec: containers: - args: - sh + {{ if eq .Values.environment "local" }} + - -c + - "/usr/sbin/sshd -D" + {{ else }} - scripts/run_web.sh + {{ end }} ports: - containerPort: 8080 + {{- if eq .Values.environment "local" }} + - containerPort: 22 + {{- end }} env: - name: DEBUG {{- if .Values.studio.debug }} @@ -144,6 +152,10 @@ spec: - name: mediavol mountPath: {{ .Values.studio.media.mount_path }} {{ end }} + {{ if eq .Values.environment "local" }} + - mountPath: /app + name: sourcecode + {{ end }} resources: limits: cpu: {{ .Values.studio.resources.limits.cpu }} @@ -175,9 +187,7 @@ spec: initialDelaySeconds: {{ .Values.studio.livenessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.studio.livenessProbe.periodSeconds }} {{- end }} - imagePullSecrets: - - name: ghcrsecret - + restartPolicy: Always volumes: {{- if .Values.chartcontroller.addSecret }} @@ -196,3 +206,9 @@ spec: persistentVolumeClaim: claimName: {{ .Release.Name }}-{{ .Values.studio.media.storage.claimName }} {{ end }} + {{ if eq .Values.environment "local" }} + - hostPath: + path: {{ .Values.source_code_path }} + type: Directory + name: sourcecode + {{ end }} diff --git a/serve/templates/studio-service.yaml b/serve/templates/studio-service.yaml index 39c2e8b..7c672ab 100644 --- a/serve/templates/studio-service.yaml +++ b/serve/templates/studio-service.yaml @@ -7,6 +7,11 @@ spec: - name: "8080" port: 8080 targetPort: 8080 + {{- if eq .Values.environment "local" }} + - name: ssh + port: 22 + targetPort: 22 + {{- end }} selector: name: {{ .Release.Name }}-{{ .Values.studio.servicename }} status: diff --git a/serve/templates/studio-settings-configmap.yaml b/serve/templates/studio-settings-configmap.yaml index a73c6a0..fc40a95 100644 --- a/serve/templates/studio-settings-configmap.yaml +++ b/serve/templates/studio-settings-configmap.yaml @@ -423,10 +423,10 @@ data: VERSION = {{ .Values.studio.version | quote }} MIGRATION_MODULES = { - 'apps': 'apps.migrations', - 'models': 'models.migrations', - 'portal': 'portal.migrations', - 'projects': 'projects.migrations', + "apps": "apps.migrations", + "models": "models.migrations", + "portal": "portal.migrations", + "projects": "projects.migrations", "common": "common.migrations", } diff --git a/serve/values.yaml b/serve/values.yaml index 9a6049b..2cff2ba 100644 --- a/serve/values.yaml +++ b/serve/values.yaml @@ -2,19 +2,28 @@ # Declare variables to be passed into STACKn templates. # REQUIREMENT: -# - set a storage class with ability to serve ReadWriteMany +# - set a storage class with ability to serve ReadWriteOnce # Name: storageClassName, and/or set anchor &śtorage_class # Description: Set a storage class for the resources that are reused for multi-mount-points in cluster. To reduce wasteful copying we allow to use the same dataset volume to be mounted multiple times. -# Default: microk8s-hostpath, use nfs-client for docker-for-desktop +# Default: microk8s-hostpath, use local-path for k3s/Rancher Desktop #Set global values to overide default +environment: "remote" +# Template for remote development +# Storage class used by the KTH cluster +storageClass: &storage_class ontap-nas +#storageClass: &storage_class local-path +#storage access mode +access_mode: &access_mode ReadWriteMany +#access_mode: &access_mode ReadWriteOnce + global: studio: superUser: "" ##these are currently not handled by stackn: default: admin superuserPassword: "" superuserEmail: "" ##these are currently not handled by stackn: default: admin@test.com existingSecret: "" - storageClass: "" + storageClass: *storage_class postgresql: auth: username: studio @@ -22,10 +31,9 @@ global: postgresPassword: "" database: studio existingSecret: "" - storageClass: - - + storageClass: *storage_class +namespace: default existingSecret: "" serviceAccount: create: true @@ -78,7 +86,7 @@ studio: replicas: 1 strategy: type: Recreate - image: ghcr.io/scilifelabdatacentre/serve/serve-ingress:develop-20240326 + image: ghcr.io/scilifelabdatacentre/serve/serve-ingress:develop-20240417 pullPolicy: IfNotPresent resources: limits: @@ -87,8 +95,8 @@ studio: requests: cpu: "100m" memory: "256Mi" - image: - repository: ghcr.io/scilifelabdatacentre/serve/serve-studio:develop-20240326 + image: + repository: ghcr.io/scilifelabdatacentre/serve/serve-studio:develop-20240417 pullPolicy: IfNotPresent resources: limits: @@ -98,12 +106,12 @@ studio: cpu: "400m" memory: "2Gi" storage: - storageClass: "" + storageClass: *storage_class media: storage: - storageClass: "" + storageClass: *storage_class size: "5Gi" - accessModes: ReadWriteMany + accessModes: *access_mode claimName: studio-media mountStudio: false mount_path: /app/media/ @@ -159,13 +167,11 @@ studio: #kubernetes config kubeconfig: "" -#storage access mode -accessmode: ReadWriteMany - +accessmode: *access_mode #the cluster domain name (default usually cluster.local) cluster_domain: cluster.local -# Enable ingress if you want your to access the studio solution from a kubernetes host/localhost. +# Enable ingress if you want to access the studio solution from a kubernetes host/localhost. domain: studio.127.0.0.1.nip.io session_cookie_domain: .127.0.0.1.nip.io ingress: @@ -203,8 +209,8 @@ postgresql: enabled: true size: "10Gi" accessModes: - - ReadWriteMany - storageClass: + - *access_mode + storageClass: *storage_class podLabels: {"app":"stackn-studio"} redis: @@ -223,21 +229,10 @@ rabbitmq: persistence: enabled: true - - -# Will be added in future realease, for now keep "enabled:false" +# Will be added in future release, for now keep "enabled:false" postgresql-ha: enabled: false -### DEPLOY SECRETS WITH private helm chart 'secrets' from platform/secrets -## Name: imagePullSecret -## Description: Secret to pull images from our private repository. -imagePullSecrets: - - name: regcred - -## to create a regcred -## kubectl create secret docker-registry regcred --docker-server= --docker-username= --docker-password= - celeryWorkers: replicas: 2 resources: From bded0be171f24e48a4d290b8d75c38138147e4aa Mon Sep 17 00:00:00 2001 From: Nikita Churikov <8545082+churnikov@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:27:33 +0300 Subject: [PATCH 02/10] SS-342 and SS-1167 allow custom commands for custom apps (#58) --- apps/custom-app/Chart.yaml | 2 +- apps/custom-app/templates/deployment.yaml | 40 ++++++++++++++++++++--- apps/custom-app/values.yaml | 1 + 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/apps/custom-app/Chart.yaml b/apps/custom-app/Chart.yaml index f6f329a..5369ddc 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.0.2 +version: 1.1.0 maintainers: - name: Team Whale email: serve@scilifelab.se diff --git a/apps/custom-app/templates/deployment.yaml b/apps/custom-app/templates/deployment.yaml index 83b1e55..0e9d113 100644 --- a/apps/custom-app/templates/deployment.yaml +++ b/apps/custom-app/templates/deployment.yaml @@ -34,8 +34,10 @@ spec: type: RuntimeDefault fsGroup: {{ .Values.appconfig.userid | default 1000 }} - {{- if .Values.apps.volumeK8s }} + {{- if or .Values.apps.volumeK8s .Values.appconfig.startupCommand }} initContainers: + {{- end}} + {{- if .Values.apps.volumeK8s }} - name: copy-to-pvc image: {{ .Values.appconfig.image }} imagePullPolicy: IfNotPresent @@ -54,8 +56,21 @@ spec: {{- range $key, $value := .Values.apps.volumeK8s }} - name: {{ $key }} mountPath: /tmp + {{- end }} {{- end }} - {{- end }} + {{- if .Values.appconfig.startupCommand}} + - name: create-startup-script + image: busybox + command: + - /bin/sh + - -c + - | + echo "{{ .Values.appconfig.startupCommand }}" > /scripts/custom-start-script.sh; + chmod +x /scripts/custom-start-script.sh; + volumeMounts: + - name: startup-script + mountPath: /scripts + {{- end}} containers: - name: {{ .Values.appname }} image: {{ .Values.appconfig.image }} @@ -63,7 +78,12 @@ spec: command: - /bin/sh - -c + {{- if .Values.appconfig.startupCommand }} + - /scripts/custom-start-script.sh; + {{- else }} - ./start-script.sh; + {{- end }} + ports: - containerPort: {{ .Values.appconfig.port }} securityContext: @@ -77,20 +97,32 @@ spec: - all resources: {{- toYaml .Values.flavor | nindent 10 }} - {{- if .Values.apps.volumeK8s }} + {{- if or .Values.appconfig.startupCommand .Values.apps.volumeK8s }} volumeMounts: + {{- end }} + {{- if .Values.apps.volumeK8s }} {{- range $key, $value := .Values.apps.volumeK8s }} - name: {{ $key }} mountPath: {{ $.Values.appconfig.path }} {{- end }} {{- end }} + {{- if .Values.appconfig.startupCommand}} + - name: startup-script + mountPath: /scripts + {{- end}} terminationGracePeriodSeconds: 30 dnsPolicy: ClusterFirst - {{ if .Values.apps.volumeK8s }} + {{ if or .Values.apps.volumeK8s .Values.appconfig.startupCommand }} volumes: + {{- end }} + {{ if .Values.apps.volumeK8s }} {{- range $key, $value := .Values.apps.volumeK8s }} - name: {{ $key }} persistentVolumeClaim: claimName: {{ $value.release }} {{- end }} {{ end }} + {{- if .Values.appconfig.startupCommand}} + - name: startup-script + emptyDir: { } + {{- end}} diff --git a/apps/custom-app/values.yaml b/apps/custom-app/values.yaml index af6c814..14f4d98 100644 --- a/apps/custom-app/values.yaml +++ b/apps/custom-app/values.yaml @@ -17,6 +17,7 @@ appconfig: port: 8501 image: ghcr.io/scilifelabdatacentre/example-streamlit:240312-1531 path: /home + startupCommand: {} service: name: customapp-svc From d5642c1d1526241b4684742b444b67d8e4facf92 Mon Sep 17 00:00:00 2001 From: Arnold Kochari Date: Wed, 30 Oct 2024 17:38:14 +0100 Subject: [PATCH 03/10] Correct LOGIN_REDIRECT_URL (#57) --- serve/templates/studio-settings-configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serve/templates/studio-settings-configmap.yaml b/serve/templates/studio-settings-configmap.yaml index fc40a95..2089549 100644 --- a/serve/templates/studio-settings-configmap.yaml +++ b/serve/templates/studio-settings-configmap.yaml @@ -330,7 +330,7 @@ data: MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') # Related to user registration and authetication workflow - LOGIN_REDIRECT_URL = '/projects' + LOGIN_REDIRECT_URL = '/projects/' LOGIN_URL = 'login' LOGOUT_URL = 'logout' INACTIVE_USERS = {{ if .Values.studio.inactive_users }}True{{ else }}False{{ end }} From f2a807dfbc4f9f42284ed4554b2457afcdb2fbf1 Mon Sep 17 00:00:00 2001 From: Hamza Date: Wed, 6 Nov 2024 16:37:58 +0100 Subject: [PATCH 04/10] add label to shinyproxy chart to trigger redeployment (#60) --- apps/shinyproxy/Chart.yaml | 2 +- apps/shinyproxy/templates/deployment.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/shinyproxy/Chart.yaml b/apps/shinyproxy/Chart.yaml index 27a4493..1f70ded 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.1 +version: 1.4.2 appVersion: "0.1" maintainers: - name: Team Whale diff --git a/apps/shinyproxy/templates/deployment.yaml b/apps/shinyproxy/templates/deployment.yaml index 982f353..df5f44f 100644 --- a/apps/shinyproxy/templates/deployment.yaml +++ b/apps/shinyproxy/templates/deployment.yaml @@ -25,6 +25,7 @@ spec: access: {{ .Values.permission }} app: shinyproxy-deployment project: {{ .Values.project.slug }} + site-dir: {{ .Values.appconfig.site_dir | trimAll "/" | replace "/" "-" }} networking/allow-internet-egress: "true" networking/allow-egress-to-studio-web: "true" allow-api-access: "true" From 20eaccafab0aa5a42e6194355559de365ef3ad86 Mon Sep 17 00:00:00 2001 From: Nikita Churikov <8545082+churnikov@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:41:15 +0100 Subject: [PATCH 05/10] SS-1141 Added info on how to setup the custom backend for the errors on k8s level (#62) --- 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 ++++++++++ ...ult-backend-error_pages.configMap-404.yaml | 4984 ++++++++++++++++ ...ult-backend-error_pages.configMap-503.yaml | 4987 +++++++++++++++++ serve/templates/custom-default-backend.yaml | 97 + serve/templates/ingress-platform.yaml | 2 + 24 files changed, 16007 insertions(+), 9 deletions(-) create mode 100644 error-page-404.html create mode 100644 error-page-503.html create mode 100644 serve/templates/custom-default-backend-error_pages.configMap-404.yaml create mode 100644 serve/templates/custom-default-backend-error_pages.configMap-503.yaml create mode 100644 serve/templates/custom-default-backend.yaml 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. +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/serve/templates/custom-default-backend-error_pages.configMap-404.yaml b/serve/templates/custom-default-backend-error_pages.configMap-404.yaml new file mode 100644 index 0000000..6e3808e --- /dev/null +++ b/serve/templates/custom-default-backend-error_pages.configMap-404.yaml @@ -0,0 +1,4984 @@ +apiVersion: v1 +data: + "404": "\n\n\n Not found | SciLifeLab Serve + (beta)\n \n \n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n
\n \n

Page + cannot be served \U0001F941 (404 error)

\n

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

\n\n
\n\n
\n
\n
\n
\n

\n \n + \
\n
\n\n
\n
\n
\n\n + \
\n
\n + \

\n + \
\n
\n\n
\n + \ \n
\n
\n + \
\n\n \n\n\n\n\n\n\n
\n\n
\n\n \n \n\n
\n
\n
    \n
\n\n
\n
\n

SciLifeLab Serve (beta) is developed and + operated by the SciLifeLab + Data Centre.\n SciLifeLab Serve is free to use for all life science researchers + \naffiliated with a Swedish research institution and their collaborators. \nThe + service is hosted on a Kubernetes cluster. The code behind \nSciLifeLab Serve + is available on Github.

\n + \

Please email serve@scilifelab.se + with any questions.

\n
\n
\n
\n
\n + \

Supported by:

\n
\n
\n + \
\n
\"SciLifeLab\"
\n
\"Swedish
\n
\"Knut
\n
\n + \
\n
\n
\n
\n\n\n \n \n\n \n\n \n \n\n\n \n \n\n\n \n\n \n + \ \n\n" +kind: ConfigMap +metadata: + name: custom-error-pages-404 + namespace: {{ .Values.namespace }} diff --git a/serve/templates/custom-default-backend-error_pages.configMap-503.yaml b/serve/templates/custom-default-backend-error_pages.configMap-503.yaml new file mode 100644 index 0000000..c5d8341 --- /dev/null +++ b/serve/templates/custom-default-backend-error_pages.configMap-503.yaml @@ -0,0 +1,4987 @@ +apiVersion: v1 +data: + "503": "\n\n\n Temporary not available | SciLifeLab + Serve (beta)\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n
\n \n

Service + is temporary unavailable (503 error)

\n\t

The + application is being created, please wait ☕️.

\n\t

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

\n\t

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

\n\n
\n\n
\n
\n
\n
\n

\n \n + \
\n
\n\n
\n
\n
\n\n + \
\n
\n + \

\n + \
\n
\n\n
\n + \ \n
\n
\n + \
\n\n \n\n\n\n\n\n\n
\n\n
\n\n \n \n\n
\n
\n
    \n
\n\n
\n
\n

SciLifeLab Serve (beta) is developed and + operated by the SciLifeLab + Data Centre.\n SciLifeLab Serve is free to use for all life science researchers + \naffiliated with a Swedish research institution and their collaborators. \nThe + service is hosted on a Kubernetes cluster. The code behind \nSciLifeLab Serve + is available on Github.

\n + \

Please email serve@scilifelab.se + with any questions.

\n
\n
\n
\n
\n + \

Supported by:

\n
\n
\n + \
\n
\"SciLifeLab\"
\n
\"Swedish
\n
\"Knut
\n
\n + \
\n
\n
\n
\n\n\n \n \n\n \n\n \n \n\n\n \n \n\n\n \n\n \n + \ \n\n" +kind: ConfigMap +metadata: + name: custom-error-pages-503 + namespace: {{ .Values.namespace }} diff --git a/serve/templates/custom-default-backend.yaml b/serve/templates/custom-default-backend.yaml new file mode 100644 index 0000000..bec79bc --- /dev/null +++ b/serve/templates/custom-default-backend.yaml @@ -0,0 +1,97 @@ +# Configuration for the default backend: service and handling of a 404 error on a subdomain level (wild card domain). +--- +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 + 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: + - host: '*.{{ .Values.domain }}' + http: + paths: + - backend: + service: + name: nginx-errors + port: + number: 80 + path: /404.html + pathType: ImplementationSpecific + tls: + - hosts: + - '*.serve-dev.scilifelab.se' + secretName: prod-ingress + diff --git a/serve/templates/ingress-platform.yaml b/serve/templates/ingress-platform.yaml index 7e53f36..13d8007 100644 --- a/serve/templates/ingress-platform.yaml +++ b/serve/templates/ingress-platform.yaml @@ -7,6 +7,8 @@ metadata: {{- with .Values.ingress.annotations }} {{- toYaml . | nindent 4 }} {{- end }} + nginx.ingress.kubernetes.io/custom-http-errors: "503" + nginx.ingress.kubernetes.io/default-backend: nginx-errors labels: io.kompose.service: {{ .Release.Name }}-ingress spec: From 8501408da30024307a6425410fbe54e1897ea10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Alfred=C3=A9en?= Date: Tue, 10 Dec 2024 10:31:51 +0100 Subject: [PATCH 06/10] Django setting CLUSTER_VERSION (#64) --- serve/templates/studio-settings-configmap.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/serve/templates/studio-settings-configmap.yaml b/serve/templates/studio-settings-configmap.yaml index 2089549..21b5c72 100644 --- a/serve/templates/studio-settings-configmap.yaml +++ b/serve/templates/studio-settings-configmap.yaml @@ -543,3 +543,6 @@ data: logger_factory=structlog.stdlib.LoggerFactory(), cache_logger_on_first_use=True, ) + + # k8s cluster version for validation of manifests + CLUSTER_VERSION = "1.28" From f3fc9325b3087dc4e447e945436fc9ecec2403a8 Mon Sep 17 00:00:00 2001 From: Mahbub Ul Alam Date: Tue, 10 Dec 2024 13:44:11 +0100 Subject: [PATCH 07/10] SS-698 set default timezone to Stockholm time (#63) Source: https://scilifelab.atlassian.net/browse/SS-698 1. Set default time zone to Stockholm time. 2. Mention it as tooltip info besides app info in /projects page. --- serve/templates/studio-settings-configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serve/templates/studio-settings-configmap.yaml b/serve/templates/studio-settings-configmap.yaml index 21b5c72..004be6f 100644 --- a/serve/templates/studio-settings-configmap.yaml +++ b/serve/templates/studio-settings-configmap.yaml @@ -318,7 +318,7 @@ data: # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ LANGUAGE_CODE = 'en-us' - TIME_ZONE = 'UTC' + TIME_ZONE = 'Europe/Stockholm' USE_I18N = True # Media Files for Studio apps From 9196d3a336b8136941affeaf7866e5417e86fd0d Mon Sep 17 00:00:00 2001 From: Nikita Churikov <8545082+churnikov@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:57:38 +0100 Subject: [PATCH 08/10] Remove custom error pages config maps (#65) --- ...ult-backend-error_pages.configMap-404.yaml | 4984 ---------------- ...ult-backend-error_pages.configMap-503.yaml | 4987 ----------------- 2 files changed, 9971 deletions(-) delete mode 100644 serve/templates/custom-default-backend-error_pages.configMap-404.yaml delete mode 100644 serve/templates/custom-default-backend-error_pages.configMap-503.yaml diff --git a/serve/templates/custom-default-backend-error_pages.configMap-404.yaml b/serve/templates/custom-default-backend-error_pages.configMap-404.yaml deleted file mode 100644 index 6e3808e..0000000 --- a/serve/templates/custom-default-backend-error_pages.configMap-404.yaml +++ /dev/null @@ -1,4984 +0,0 @@ -apiVersion: v1 -data: - "404": "\n\n\n Not found | SciLifeLab Serve - (beta)\n \n \n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n
\n \n

Page - cannot be served \U0001F941 (404 error)

\n

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

\n\n
\n\n
\n
\n
\n
\n

\n \n - \
\n
\n\n
\n
\n
\n\n - \
\n
\n - \

\n - \
\n
\n\n
\n - \ \n
\n
\n - \
\n\n \n\n\n\n\n\n\n
\n\n
\n\n \n \n\n
\n
\n
    \n
\n\n
\n
\n

SciLifeLab Serve (beta) is developed and - operated by the SciLifeLab - Data Centre.\n SciLifeLab Serve is free to use for all life science researchers - \naffiliated with a Swedish research institution and their collaborators. \nThe - service is hosted on a Kubernetes cluster. The code behind \nSciLifeLab Serve - is available on Github.

\n - \

Please email serve@scilifelab.se - with any questions.

\n
\n
\n
\n
\n - \

Supported by:

\n
\n
\n - \
\n
\"SciLifeLab\"
\n
\"Swedish
\n
\"Knut
\n
\n - \
\n
\n
\n
\n\n\n \n \n\n \n\n \n \n\n\n \n \n\n\n \n\n \n - \ \n\n" -kind: ConfigMap -metadata: - name: custom-error-pages-404 - namespace: {{ .Values.namespace }} diff --git a/serve/templates/custom-default-backend-error_pages.configMap-503.yaml b/serve/templates/custom-default-backend-error_pages.configMap-503.yaml deleted file mode 100644 index c5d8341..0000000 --- a/serve/templates/custom-default-backend-error_pages.configMap-503.yaml +++ /dev/null @@ -1,4987 +0,0 @@ -apiVersion: v1 -data: - "503": "\n\n\n Temporary not available | SciLifeLab - Serve (beta)\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n
\n \n

Service - is temporary unavailable (503 error)

\n\t

The - application is being created, please wait ☕️.

\n\t

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

\n\t

If the problem - persists please contact us via serve@scilifelab.se - and describe the issue.\n\t

\n\n
\n\n
\n
\n
\n
\n

\n \n - \
\n
\n\n
\n
\n
\n\n - \
\n
\n - \

\n - \
\n
\n\n
\n - \ \n
\n
\n - \
\n\n \n\n\n\n\n\n\n
\n\n
\n\n \n \n\n
\n
\n
    \n
\n\n
\n
\n

SciLifeLab Serve (beta) is developed and - operated by the SciLifeLab - Data Centre.\n SciLifeLab Serve is free to use for all life science researchers - \naffiliated with a Swedish research institution and their collaborators. \nThe - service is hosted on a Kubernetes cluster. The code behind \nSciLifeLab Serve - is available on Github.

\n - \

Please email serve@scilifelab.se - with any questions.

\n
\n
\n
\n
\n - \

Supported by:

\n
\n
\n - \
\n
\"SciLifeLab\"
\n
\"Swedish
\n
\"Knut
\n
\n - \
\n
\n
\n
\n\n\n \n \n\n \n\n \n \n\n\n \n \n\n\n \n\n \n - \ \n\n" -kind: ConfigMap -metadata: - name: custom-error-pages-503 - namespace: {{ .Values.namespace }} From af0d86487ecfe47b128d1a9a99bfd2b0a5d1de02 Mon Sep 17 00:00:00 2001 From: Nikita Churikov <8545082+churnikov@users.noreply.github.com> Date: Wed, 11 Dec 2024 12:05:46 +0100 Subject: [PATCH 09/10] Download error pages form the github in the init container (#66) --- .../error-page-404.html | 226 +- k8s-error-pages/error-page-500.html | 2907 +++++++++++++++++ k8s-error-pages/error-page-502.html | 2907 +++++++++++++++++ .../error-page-503.html | 228 +- serve/templates/custom-default-backend.yaml | 49 +- serve/templates/ingress-platform.yaml | 2 +- 6 files changed, 6017 insertions(+), 302 deletions(-) rename error-page-404.html => k8s-error-pages/error-page-404.html (81%) create mode 100644 k8s-error-pages/error-page-500.html create mode 100644 k8s-error-pages/error-page-502.html rename error-page-503.html => k8s-error-pages/error-page-503.html (81%) diff --git a/error-page-404.html b/k8s-error-pages/error-page-404.html similarity index 81% rename from error-page-404.html rename to k8s-error-pages/error-page-404.html index 3feb67b..5f6797e 100644 --- a/error-page-404.html +++ b/k8s-error-pages/error-page-404.html @@ -1,22 +1,17 @@ - - - Not found | SciLifeLab Serve (beta) - - - - - - - - - - - - - - + + +Not found | SciLifeLab Serve (beta) + + + + + + + - - ")}}function zn(){const e=ne().querySelector('meta[name="htmx-config"]');if(e){return S(e.content)}else{return null}}function Jn(){const e=zn();if(e){Q.config=ue(Q.config,e)}}_n(function(){Jn();$n();let e=ne().body;kt(e);const t=ne().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){const t=e.target;const n=ie(t);if(n&&n.xhr){n.xhr.abort()}});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){Yt();se(t,function(e){he(e,"htmx:restored",{document:ne(),triggerEvent:he})})}else{if(n){n(e)}}};E().setTimeout(function(){he(e,"htmx:load",{});e=null},0)});return Q}(); - - - - - - + - - - - -
- -

Page cannot be served 🥁 (404 error)

-

It's okay, don't worry. Just go to the home page +

+

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.

- -
- - - - - - - - - - +
+