diff --git a/.github/workflows/code-checks.yaml b/.github/workflows/code-checks.yaml deleted file mode 100644 index 80e1b71..0000000 --- a/.github/workflows/code-checks.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: Code-check charts - -on: - push: - branches: - - main - - develop - pull_request: - branches: - - main - - develop - release: - types: [published] - -jobs: - check-code: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - - name: Install Helm - id: install_helm - run: | - curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 - chmod 700 get_helm.sh - ./get_helm.sh - - - name: Lint helm chart - run: | - cd scaleout/stackn - helm lint --debug . \ No newline at end of file diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml new file mode 100644 index 0000000..8ffa20d --- /dev/null +++ b/.github/workflows/lint-test.yaml @@ -0,0 +1,48 @@ +name: Lint and Test Charts + +on: + pull_request: + workflow_dispatch: + + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v3.5 + with: + version: v3.13.0 + + - name: Set up Python + uses: actions/setup-python@v4.7.1 + with: + python-version: 3.12 + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.1 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --chart-dirs apps --target-branch main) + if [[ -n "$changed" ]]; then + echo "changed=true" >> $GITHUB_OUTPUT + fi + + - name: Run chart-testing (lint) + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --chart-dirs apps --all --target-branch main --validate-maintainers=false + + - name: Create kind cluster + if: steps.list-changed.outputs.changed == 'true' + uses: helm/kind-action@v1.8.0 + + - name: Run chart-testing (install) + if: steps.list-changed.outputs.changed == 'true' + run: ct install --chart-dirs apps --all --target-branch main --excluded-charts shinyproxy,volumek8s \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d9f74a6..dd25950 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,60 +1,54 @@ -name: Release Helm charts +name: Release Charts on: - release: - types: [published] + push: + branches: + - main + workflow_dispatch: +permissions: + contents: write + packages: write jobs: - sync-branch: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Merge base branch -> gh-pages - uses: devmasx/merge-branch@v1.3.1 - with: - type: now - from_branch: ${{ github.base_ref }} - target_branch: gh-pages - github_token: ${{ github.token }} - - chart-releaser: - runs-on: ubuntu-20.04 - needs: sync-branch + release: + runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: - ref: gh-pages + fetch-depth: 0 - name: Configure Git run: | - echo "GITHUB_ACTOR: $GITHUB_ACTOR" - git config --global user.name "$GITHUB_ACTOR" - git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" - + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Install Helm - run: | - curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 - chmod 700 get_helm.sh - ./get_helm.sh + uses: azure/setup-helm@v3.5 + with: + version: 3.13.0 - - name: Add chart dependencies - run: | - helm repo add stable https://charts.helm.sh/stable - - - name: Update index.yaml and helm package - run: | - cd scaleout/stackn - helm package . - helm repo index . --url https://scaleoutsystems.github.io/charts/scaleout/stackn --merge index.yaml + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + with: + charts_dir: apps + skip_existing: true + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Commit index.yaml and helm package to gh-pages + - name: Push Charts to GHCR run: | - git pull origin gh-pages - git add -A - git commit -m "Updated index.yaml and helm package" - git push origin gh-pages - + for pkg in .cr-release-packages/*; do + if [ -z "${pkg:-}" ]; then + break + fi + helm push "${pkg}" oci://ghcr.io/scilifelabdatacentre/serve-charts || true + done \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2d947ef..5ec83de 100644 --- a/.gitignore +++ b/.gitignore @@ -135,3 +135,6 @@ repos/ #Other values-local* + +/tmpcharts +requirements.lock \ No newline at end of file diff --git a/LICENSE b/LICENSE index e03e768..cd482d8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,10 +1,198 @@ -Copyright 2020 Scaleout Systems AB +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/README.md b/README.md index d7cfaaa..344d54d 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,122 @@ -## Info +# SciLifeLab Serve -This repository contains Helm charts maintained by Scaleout Systems AB. The repo index is hosted by GitHub pages. +SciLifeLab Serve ([https://serve.scilifelab.se](https://serve.scilifelab.se)) is a platform offering machine learning model serving, app hosting (Shiny, Streamlit, Dash, etc.), web-based integrated development environments, and other tools to life science researchers affiliated with a Swedish research institute. It is developed and operated by the [SciLifeLab Data Centre](https://github.com/ScilifelabDataCentre), part of [SciLifeLab](https://scilifelab.se/). See [this page for information about funders and mandate](https://serve.scilifelab.se/about/). -**Note:** The main branch is now the new default branch. For getting the latest version of these charts please clone the main branch and not the master. +This repository contains Helm charts for SciLifeLab Serve. It is based on the open-source platform [Stackn](https://github.com/scaleoutsystems/stackn). +## Reporting bugs and requesting features -## Getting started -To be able to deploy Helm charts from this repository you first need to add this repository as a source of charts. +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/stackn/issues/new/choose) with a bug report or feature request. -```bash -$ helm repo add scaleout https://scaleoutsystems.github.io/charts/scaleout/stackn +## How to deploy +First, clone this repository ``` +git clone https://github.com/ScilifelabDataCentre/serve-charts.git +``` + +Then navigate to the `serve-charts/serve` folder, and run + +``` +helm dependency update +helm install serve . +``` + +Depending on your storageclass, you might have to set this aswell. +For instance, if you use `microk8s`, them you run -Deploy a chart -```bash -$ helm install stackn scaleout/stackn -f ``` +helm install --set global.postgresql.storageClass=microk8s-hostpath serve . +``` + +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. + + +## Deploy an SSL certificate + +For production you need a domain name with a wildcard SSL certificate. If your domain is your-domain.com, you will need a certificate for *.your-domain.com and *.studio.your-domain.com. Assuming that your certificate is fullchain.pem and your private key privkey.pem, you can create a secret `prod-ingress` containing the certificate with the command: +``` +kubectl create secret tls prod-ingress --cert fullchain.pem --key privkey.pem +``` + +This secret should be in the same namespace as studio deployment. + +## Enabling network policies +If networkPolicy.enable = true, you have to make sure the correct kubernetes endpoint IP is provided in networkPolicy.kubernetes.cidr, and the correct port networkPolicy.kubernetes.port. This is to enable access of some services to the kubernetes API server through a created Service Account. To get your cluster's kubernetes endpoint run: +``` +kubectl get endpoints kubernetes +``` +To allow for within-cluster DNS, the kube-system namespace need the label: +``` +kubectl label namespace kube-system name=kube-system +``` + +Further, for ingress resources you need to set networkPolicy.ingress_controller_namespace. If value can vary depending on your cluster configuration, but for NGINX ingress controller it's usually "ingress-nginx". + +## Example deployment +``` +global: + studio: + superuserPassword: adminstudio # Django superuser password, username is admin + postgresql: + auth: + username: studio + password: studiopostgrespass + postgresPassword: postgres + database: studio + storageClass: local-path + + +networkPolicy: + enable: true + kubernetes: + cidr: 127.0.0.1/32 # To get kubernetes api server endpoints run: $ kubectl get endpoints kubernetes + port: 6443 + internal_cidr: # in-cluster IpBlock cidr, used in allow-internet-[egress|ingress] policy, e.g: + - 10.0.0.0/8 + - 192.168.0.0/16 + - 172.0.0.0/20 + +studio: + debug: false + 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) + 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) + media: + storage: + accessModes: ReadWriteOnce + +accessmode: ReadWriteOnce + +# Postgres deploy with a single-pod database: +postgresql: + primary: + persistence: + size: "2Gi" + accessModes: + - ReadWriteOnce + storageClass: local-path + +rabbit: + password: rabbitmqpass + +redis: + master: + persistence: + enabled: false + replica: + persistence: + enabled: false -### Local configs -If you want local configurations place them in a directory named configs/ as the .gitignore will ignore that foldername and contents. +celeryFlower: + enabled: false -## License -APACHE 2.0 +reloader: + enabled: true +``` \ No newline at end of file diff --git a/STACK.md b/STACK.md deleted file mode 100644 index 44d71aa..0000000 --- a/STACK.md +++ /dev/null @@ -1,38 +0,0 @@ - -## Installing prereqs -As helmchart are not currently supporting checking if a namespace exist before applying there is a prereqs file that must be applied in the cluster. -```bash -kubectl apply -f prereq-stack.yaml -``` - -### Install argo CRDs -> This step is only done once before the initial deployment of helm charts. If you redeploy helm charts this doesnt need to be re-run. - -```bash -kubectl apply -f https://raw.githubusercontent.com/argoproj/argo/master/manifests/base/crds/workflow-crd.yaml -kubectl apply -f https://github.com/argoproj/argo-events/raw/v0.11/hack/k8s/manifests/sensor-crd.yaml -kubectl apply -f https://github.com/argoproj/argo-events/raw/v0.11/hack/k8s/manifests/gateway-crd.yaml -``` - -## Edit values -Starting from Helm v.3.0.3 there is now a way to get the default values out of the helm chart direcly. -Running -```bash -helm show values scaleout/stack >> local-values.yaml -``` -will give you a local-values.yaml to edit that is a copy of the default values. - - -## Installing the stack helmchart - -1. Installing with default values - -```bash -helm install your-release-name stack -``` - -2. Installing with your custom values - -```bash -helm install your-release-name stack --values=local-values.yaml -``` diff --git a/apps/custom-app/Chart.yaml b/apps/custom-app/Chart.yaml new file mode 100644 index 0000000..e6fbf91 --- /dev/null +++ b/apps/custom-app/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for a standard serve app +name: custom-app +version: 1.0.1 +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/custom-app/templates/deployment.yaml b/apps/custom-app/templates/deployment.yaml new file mode 100644 index 0000000..e9a866a --- /dev/null +++ b/apps/custom-app/templates/deployment.yaml @@ -0,0 +1,99 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Release.Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + # prometheus.io/port: "8501" + labels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-egress-to-studio-web: "true" + type: app + pod: {{ .Values.appname }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: false + securityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: {{ .Values.appconfig.userid | default 1000 }} + + {{- if .Values.apps.volumeK8s }} + initContainers: + - name: copy-to-pvc + image: {{ .Values.appconfig.image }} + imagePullPolicy: IfNotPresent + command: + - /bin/sh + - -c + - | + if [ -n "$(ls -A {{ $.Values.appconfig.path }})" ]; then + echo "Copying data..." && cp -r -n {{ $.Values.appconfig.path }}/* /tmp && echo "Done Copying"; + elif [ -d "{{ $.Values.appconfig.path }}" ]; then + echo "Empty directory. Nothing to copy."; + else + echo "Directory does not exist" && cp -r -n {{ $.Values.appconfig.path }}/* /tmp; + fi + volumeMounts: + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + mountPath: /tmp + {{- end }} + {{- end }} + containers: + - name: {{ .Values.appname }} + image: {{ .Values.appconfig.image }} + imagePullPolicy: IfNotPresent + command: + - /bin/sh + - -c + - ./start-script.sh; + ports: + - containerPort: {{ .Values.appconfig.port }} + securityContext: + runAsNonRoot: true + runAsUser: {{ .Values.appconfig.userid | default 1000 }} + runAsGroup: {{ .Values.appconfig.userid | default 1000 }} + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all + resources: + {{- toYaml .Values.flavor | nindent 10 }} + {{- if .Values.apps.volumeK8s }} + volumeMounts: + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + mountPath: {{ $.Values.appconfig.path }} + {{- end }} + {{- end }} + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + {{ if .Values.apps.volumeK8s }} + volumes: + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + persistentVolumeClaim: + claimName: {{ $value.release }} + {{- end }} + {{ end }} diff --git a/apps/custom-app/templates/ingress.yaml b/apps/custom-app/templates/ingress.yaml new file mode 100644 index 0000000..1dc5e65 --- /dev/null +++ b/apps/custom-app/templates/ingress.yaml @@ -0,0 +1,28 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + {{ if and (ne .Values.permission "public") (ne .Values.permission "link") }} + 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 }} +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: {{ .Values.service.port }} + pathType: ImplementationSpecific + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Values.global.domain }} diff --git a/apps/custom-app/templates/service.yaml b/apps/custom-app/templates/service.yaml new file mode 100644 index 0000000..179b1e2 --- /dev/null +++ b/apps/custom-app/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Release.Namespace }} + labels: + run: {{ .Release.Name }}-customapp +spec: + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.appconfig.port }} + selector: + release: {{ $.Release.Name }} diff --git a/apps/custom-app/templates/tests/test-connection.yaml b/apps/custom-app/templates/tests/test-connection.yaml new file mode 100644 index 0000000..e1e6260 --- /dev/null +++ b/apps/custom-app/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: {{ .Release.Name }}-test-connection + labels: + Release: {{ .Release.Name }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ["wget"] + args: ["--no-check-certificate", "{{ .Values.service.name }}:{{ .Values.service.port }}"] + restartPolicy: Never \ No newline at end of file diff --git a/apps/custom-app/values.yaml b/apps/custom-app/values.yaml new file mode 100644 index 0000000..a3879e2 --- /dev/null +++ b/apps/custom-app/values.yaml @@ -0,0 +1,54 @@ +appname: customapp +project: + name: project + slug: project-slug + +permission: public + +global: + protocol: TCP + domain: studio.127.0.0.1.nip.io + auth_domain: studio.127.0.0.1.nip.io + +apps: + volumeK8s: + +appconfig: + port: 8501 + image: ghcr.io/scilifelabdatacentre/example-streamlit:240312-1531 + path: /home + +service: + name: customapp-svc + port: 80 + +imagePullSecrets: + - name: regcred + +ingress: + secretName: prod-ingress + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all + +flavor: + limits: + cpu: 1 + ephemeral-storage: 800Mi + memory: 1Gi + requests: + cpu: 500m + ephemeral-storage: 500Mi + memory: 500Mi diff --git a/apps/dash/Chart.yaml b/apps/dash/Chart.yaml new file mode 100644 index 0000000..c60d175 --- /dev/null +++ b/apps/dash/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart Dash apps +name: dash-app +version: 1.0.1 +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/dash/templates/deployment.yaml b/apps/dash/templates/deployment.yaml new file mode 100644 index 0000000..dc5b8a9 --- /dev/null +++ b/apps/dash/templates/deployment.yaml @@ -0,0 +1,48 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Release.Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + # prometheus.io/port: "8501" + labels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-egress-to-studio-web: "true" + type: app + pod: {{ .Values.appname }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Values.appname }} + image: {{ .Values.appconfig.image }} + imagePullPolicy: IfNotPresent + ports: + - containerPort: {{ .Values.appconfig.port }} + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst diff --git a/apps/dash/templates/ingress.yaml b/apps/dash/templates/ingress.yaml new file mode 100644 index 0000000..1dc5e65 --- /dev/null +++ b/apps/dash/templates/ingress.yaml @@ -0,0 +1,28 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + {{ if and (ne .Values.permission "public") (ne .Values.permission "link") }} + 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 }} +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: {{ .Values.service.port }} + pathType: ImplementationSpecific + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Values.global.domain }} diff --git a/apps/dash/templates/service.yaml b/apps/dash/templates/service.yaml new file mode 100644 index 0000000..c4f931b --- /dev/null +++ b/apps/dash/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Release.Namespace }} + labels: + run: {{ .Release.Name }}-dashapp +spec: + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.appconfig.port }} + selector: + release: {{ $.Release.Name }} diff --git a/apps/dash/templates/tests/test-connection.yaml b/apps/dash/templates/tests/test-connection.yaml new file mode 100644 index 0000000..be0733a --- /dev/null +++ b/apps/dash/templates/tests/test-connection.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Pod +metadata: + name: {{ .Release.Name }}-test-connection + namespace: {{ .Release.Namespace }} + labels: + Release: {{ .Release.Name }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ["wget"] + args: ["--no-check-certificate", "{{ .Values.service.name }}:{{ .Values.service.port }}"] + restartPolicy: Never \ No newline at end of file diff --git a/apps/dash/values.yaml b/apps/dash/values.yaml new file mode 100644 index 0000000..e89640f --- /dev/null +++ b/apps/dash/values.yaml @@ -0,0 +1,42 @@ +appname: dashapp +project: + name: project + slug: project-slug + +permission: public + +global: + protocol: TCP + domain: studio.127.0.0.1.nip.io + auth_domain: studio.127.0.0.1.nip.io + +appconfig: + port: 8000 + image: ghcr.io/scilifelabdatacentre/example-dash:latest + +service: + name: dashapp-svc + port: 80 + +imagePullSecrets: + - name: regcred + +ingress: + secretName: prod-ingress + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all + +flavor: {} diff --git a/apps/filemanager/Chart.yaml b/apps/filemanager/Chart.yaml new file mode 100644 index 0000000..e2c5992 --- /dev/null +++ b/apps/filemanager/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for the serve File Manager +name: filemanager +version: 1.0.2 +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/filemanager/templates/deployment.yaml b/apps/filemanager/templates/deployment.yaml new file mode 100644 index 0000000..3570665 --- /dev/null +++ b/apps/filemanager/templates/deployment.yaml @@ -0,0 +1,59 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }} + namespace: {{ .Release.Namespace }} + annotations: + reloader.stakater.com/auto: "true" +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + release: {{ .Release.Name }} + app: filemanager + project: {{ .Values.project.slug }} + type: app + pod: filemanager + template: + metadata: + labels: + release: {{ .Release.Name }} + app: filemanager + project: {{ .Values.project.slug }} + networking/allow-internet-egress: "false" + type: app + pod: filemanager + spec: + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Release.Name }}-filemanager + image: {{ .Values.appconfig.image }} + imagePullPolicy: IfNotPresent + env: + - name: FB_USERNAME + value: dummyvalue + - name: FB_PASSWORD + value: dummyvalue123 + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + ports: + - containerPort: {{ .Values.service.port }} + resources: {} + volumeMounts: + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + mountPath: /srv/{{ $key }} + {{- end }} + hostname: {{ .Release.Name }}-filemanager + restartPolicy: Always + volumes: + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + persistentVolumeClaim: + claimName: {{ $value.release }} + {{- end }} +status: {} diff --git a/apps/filemanager/templates/ingress.yaml b/apps/filemanager/templates/ingress.yaml new file mode 100644 index 0000000..61aebbf --- /dev/null +++ b/apps/filemanager/templates/ingress.yaml @@ -0,0 +1,29 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + nginx.ingress.kubernetes.io/proxy-body-size: "10000M" + {{- if ne .Values.permission "public" }} + 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 }} + name: {{ .Release.Name }}-filemanager-ingress + namespace: {{ .Release.Namespace }} +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: {{ .Values.service.port }} + pathType: ImplementationSpecific + + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Values.global.domain }} + \ No newline at end of file diff --git a/apps/filemanager/templates/service.yaml b/apps/filemanager/templates/service.yaml new file mode 100644 index 0000000..bbc3149 --- /dev/null +++ b/apps/filemanager/templates/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Release.Namespace }} +spec: + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + + selector: + release: {{ .Release.Name }} diff --git a/apps/filemanager/templates/tests/test-connection.yaml b/apps/filemanager/templates/tests/test-connection.yaml new file mode 100644 index 0000000..e1e6260 --- /dev/null +++ b/apps/filemanager/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: {{ .Release.Name }}-test-connection + labels: + Release: {{ .Release.Name }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ["wget"] + args: ["--no-check-certificate", "{{ .Values.service.name }}:{{ .Values.service.port }}"] + restartPolicy: Never \ No newline at end of file diff --git a/apps/filemanager/values.yaml b/apps/filemanager/values.yaml new file mode 100644 index 0000000..32e10d8 --- /dev/null +++ b/apps/filemanager/values.yaml @@ -0,0 +1,40 @@ +appname: filemanager +project: + name: project + slug: project-slug + +permission: public + +global: + protocol: TCP + domain: studio.127.0.0.1.nip.io + auth_domain: studio.127.0.0.1.nip.io + +ingress: + secretName: prod-ingress + +apps: + volumeK8s: {} + +appconfig: + image: ghcr.io/scilifelabdatacentre/serve-filemanager:240221-0930 + +service: + name: filemanager-svc + port: 8080 + targetPort: 8080 + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all diff --git a/apps/jupyter-lab/Chart.yaml b/apps/jupyter-lab/Chart.yaml new file mode 100644 index 0000000..afb1ad8 --- /dev/null +++ b/apps/jupyter-lab/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for Jupyter Lab +name: lab +version: 1.0.0 +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/jupyter-lab/templates/configmap.yaml b/apps/jupyter-lab/templates/configmap.yaml new file mode 100644 index 0000000..feaf073 --- /dev/null +++ b/apps/jupyter-lab/templates/configmap.yaml @@ -0,0 +1,71 @@ + +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-jupyter-configmap + namespace: {{ .Release.Namespace }} +data: + # Configuration values can be set as key-value properties + jupyter_notebook_config.py: |- + # Copyright (c) Jupyter Development Team. + # Distributed under the terms of the Modified BSD License. + + from jupyter_core.paths import jupyter_data_dir + import subprocess + import os + import errno + import stat + + c = get_config() + c.ServerApp.ip = '0.0.0.0' + c.ServerApp.port = 8888 + c.ServerApp.open_browser = False + c.ServerApp.token = '' + c.ServerApp.tornado_settings={'headers':{'Content-Security-Policy': 'frame-ancestors self http://{{ .Values.global.domain }}',} } + + c.ServerApp.allow_origin = '*' + c.ServerApp.allow_remote_access = True + + # https://github.com/jupyter/notebook/issues/3130 + c.FileContentsManager.delete_to_trash = False + + + + # Generate a self-signed certificate + if 'GEN_CERT' in os.environ: + dir_name = jupyter_data_dir() + pem_file = os.path.join(dir_name, 'notebook.pem') + try: + os.makedirs(dir_name) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(dir_name): + pass + else: + raise + + # Generate an openssl.cnf file to set the distinguished name + cnf_file = os.path.join(os.getenv('CONDA_DIR', '/usr/lib'), 'ssl', 'openssl.cnf') + if not os.path.isfile(cnf_file): + with open(cnf_file, 'w') as fh: + fh.write('''\ + [req] + distinguished_name = req_distinguished_name + [req_distinguished_name] + ''') + + # Generate a certificate if one doesn't exist on disk + subprocess.check_call(['openssl', 'req', '-new', + '-newkey', 'rsa:2048', + '-days', '365', + '-nodes', '-x509', + '-subj', '/C=XX/ST=XX/L=XX/O=generated/CN=generated', + '-keyout', pem_file, + '-out', pem_file]) + # Restrict access to the file + os.chmod(pem_file, stat.S_IRUSR | stat.S_IWUSR) + c.NotebookApp.certfile = pem_file + + # Change default umask for all subprocesses of the notebook server if set in + # the environment + if 'NB_UMASK' in os.environ: + os.umask(int(os.environ['NB_UMASK'], 8)) diff --git a/apps/jupyter-lab/templates/deployment.yaml b/apps/jupyter-lab/templates/deployment.yaml new file mode 100644 index 0000000..cce794a --- /dev/null +++ b/apps/jupyter-lab/templates/deployment.yaml @@ -0,0 +1,97 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Release.Namespace }} + annotations: + reloader.stakater.com/auto: "true" +spec: + replicas: 1 + selector: + matchLabels: + release: {{ .Release.Name }} + app: {{ .Values.appname }} + project: {{ .Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + # prometheus.io/port: "8501" + labels: + release: {{ .Release.Name }} + app: {{ .Values.appname }} + project: {{ .Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-egress-to-studio-web: "true" + type: app + pod: {{ .Values.appname }} + spec: + {{ if index .Values.flavor.limits "nvidia.com/gpu" }} + affinity: + {{ .Values.affinity | toYaml | nindent 8 | trim }} + {{ end }} + automountServiceAccountToken: false + hostname: lab + subdomain: default-subdomain + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: jupyter-lab + image: {{ .Values.appconfig.image }} + imagePullPolicy: IfNotPresent + ports: + - containerPort: {{ .Values.appconfig.port }} + env: + - name: JUPYTER_ENABLE_LAB + value: "yes" + - name: NOTEBOOK_PASSWD_SHA1 + value: "" + - name: NOTEBOOK_TOKEN + value: "" + - name: MLFLOW_TRACKING_URI + value: "http://{{ .Values.mlflow.service }}:{{ .Values.mlflow.port }}" + - name: MLFLOW_TRACKING_USERNAME + value: {{ .Values.mlflow.username }} + - name: MLFLOW_TRACKING_PASSWORD + value: {{ .Values.mlflow.password }} + - name: MLFLOW_S3_ENDPOINT_URL + value: "http://{{ .Values.mlflow.s3service }}:{{ .Values.mlflow.s3port }}" + - name: AWS_ACCESS_KEY_ID + value: {{ .Values.mlflow.access_key }} + - name: AWS_SECRET_ACCESS_KEY + value: {{ .Values.mlflow.secret_key }} + {{- range $key, $value := .Values.app_env }} + - name: {{ $key }} + value: "{{ $value }}" + {{- end }} + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + workingDir: /home/jovyan/work + volumeMounts: + - name: jupyterconf + mountPath: /etc/jupyter/jupyter_notebook_config.py + subPath: jupyter_notebook_config.py + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + mountPath: /home/jovyan/work/{{ $key }} + {{- end }} + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + volumes: + - name: jupyterconf + configMap: + name: {{ .Release.Name }}-jupyter-configmap + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + persistentVolumeClaim: + claimName: {{ $value.release }} + {{- end }} diff --git a/apps/jupyter-lab/templates/ingress.yaml b/apps/jupyter-lab/templates/ingress.yaml new file mode 100644 index 0000000..e3f1834 --- /dev/null +++ b/apps/jupyter-lab/templates/ingress.yaml @@ -0,0 +1,58 @@ +{{ if .Values.ingress.v1beta1 }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + nginx.ingress.kubernetes.io/proxy-body-size: "5500m" + 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 +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + serviceName: {{ .Values.service.name }} + servicePort: {{ .Values.service.port }} + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Release.Name }}.{{ .Values.global.domain }} + +{{ else }} + +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + annotations: + nginx.ingress.kubernetes.io/proxy-body-size: "5500m" + nginx.ingress.kubernetes.io/ssl-redirect: "true" + 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 +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: {{ .Values.service.port }} + pathType: ImplementationSpecific + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Release.Name }}.{{ .Values.global.domain }} + +{{- end }} diff --git a/apps/jupyter-lab/templates/service.yaml b/apps/jupyter-lab/templates/service.yaml new file mode 100644 index 0000000..2e4b3d1 --- /dev/null +++ b/apps/jupyter-lab/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Release.Namespace }} + labels: + run: {{ .Release.Name }} + app: jupyter-lab +spec: + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetport }} + selector: + release: {{ .Release.Name }} diff --git a/apps/jupyter-lab/values.yaml b/apps/jupyter-lab/values.yaml new file mode 100644 index 0000000..28f1ce5 --- /dev/null +++ b/apps/jupyter-lab/values.yaml @@ -0,0 +1,76 @@ +appname: jupyter-lab +project: + name: project + slug: project-slug + +affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: acceleration + operator: In + values: + - gpu + +global: + domain: localhost + +apps: + volumek8s: + +imagePullSecrets: + - name: regcred + +minio: + access_key: minio + secret_key: minio123 + bucket: dataset + +appconfig: + port: 8888 + image: ghcr.io/scilifelabdatacentre/serve-jupyterlab:231030-1145 + +service: + name: jupyterlab-svc + port: 80 + +ingress: + v1beta1: false + secretName: prod-ingress + +mlflow: + url: "" + s3url: "" + access_key: "" + secret_key: "" + region: "" + username: "" + password: "" + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 100 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 100 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all + +flavor: + limits: + cpu: 1 + ephemeral-storage: 800Mi + memory: 1Gi + nvidia.com/gpu: + requests: + cpu: 500m + ephemeral-storage: 500Mi + memory: 500Mi + nvidia.com/gpu: diff --git a/apps/mlflow-serve/chart/Chart.yaml b/apps/mlflow-serve/chart/Chart.yaml new file mode 100644 index 0000000..f969341 --- /dev/null +++ b/apps/mlflow-serve/chart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for Model Deployment +name: model-deployment +version: 0.0.1 diff --git a/apps/mlflow-serve/chart/templates/deployment.yaml b/apps/mlflow-serve/chart/templates/deployment.yaml new file mode 100644 index 0000000..373554c --- /dev/null +++ b/apps/mlflow-serve/chart/templates/deployment.yaml @@ -0,0 +1,124 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Values.namespace }} + labels: + app: {{ .Values.appname }} + annotations: + reloader.stakater.com/auto: "true" +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + release: {{ .Release.Name }} + app: {{ .Values.appname }} + project: {{ .Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + prometheus.io/port: "8501" + labels: + release: {{ .Release.Name }} + app: {{ .Values.appname }} + project: {{ .Values.project.slug }} + networking/allow-internet-egress: "true" + type: app + pod: {{ .Values.appname }} + spec: + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + volumes: + - name: rp-conf + configMap: + name: {{ .Release.Name }}-rp-config + {{ if .Values.model_card.enabled }} + - name: mc-conf + configMap: + name: {{ .Release.Name }}-mc-config + {{ end }} + - name: model-vol + emptyDir: {} + initContainers: + - name: copy-model + image: minio/mc + imagePullPolicy: Always + command: ["/bin/bash"] + {{ if eq .Values.model.type "model" }} + args: ["-c", "mc config host add projminio $S3_ENDPOINT $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;mc cp projminio/$STACKN_MODEL_BUCKET/$STACKN_MODEL_FILE /models/model.tar.gz"] + {{ else }} + args: ["-c", "mc config host add projminio $S3_ENDPOINT $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;mc cp -r projminio/$STACKN_MODEL_BUCKET/$STACKN_MODEL_PATH /models/"] + {{ end }} + volumeMounts: + - name: model-vol + mountPath: /models + env: + - name: S3_ACCESS_KEY_ID + value: {{ .Values.model.access_key }} + - name: S3_SECRET_ACCESS_KEY + value: {{ .Values.model.secret_key }} + - name: S3_ENDPOINT + value: {{ .Values.model.url }} + - name: STACKN_MODEL_BUCKET + value: {{ .Values.model.bucket }} + - name: STACKN_MODEL_FILE + value: {{ .Values.model.obj }} + - name: STACKN_MODEL_PATH + value: {{ .Values.model.path }} + {{ if eq .Values.model.type "model" }} + - name: extract-model + image: busybox + imagePullPolicy: Always + command: ["/bin/sh"] + args: ["-c", "cd /models && tar xvf model.tar.gz"] + volumeMounts: + - name: model-vol + mountPath: /models + {{ end }} + containers: + - name: reverse-proxy + image: nginxinc/nginx-unprivileged:latest + imagePullPolicy: Always + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + volumeMounts: + - name: rp-conf + mountPath: /etc/nginx + {{ if .Values.model_card.enabled }} + - name: model-card + image: nginxinc/nginx-unprivileged:latest + imagePullPolicy: Always + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + volumeMounts: + - name: model-vol + mountPath: /model + - name: mc-conf + mountPath: /etc/nginx + {{ end }} + - name: serve + command: ["/bin/sh"] + args: ["-c", "mlflow models serve -m /models/model -h 0.0.0.0"] + image: {{ .Values.appconfig.image }} + imagePullPolicy: Always + ports: + - containerPort: {{ .Values.appconfig.port }} + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + volumeMounts: + - name: model-vol + mountPath: /models + {{- with .Values.extraVolumeMounts }} + {{- tpl . $ | nindent 8 }} + {{- end }} diff --git a/apps/mlflow-serve/chart/templates/hpa.yaml b/apps/mlflow-serve/chart/templates/hpa.yaml new file mode 100644 index 0000000..98ca7eb --- /dev/null +++ b/apps/mlflow-serve/chart/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{ if .Values.hpa.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Values.appname }}-hpa + namespace: {{ .Values.namespace }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Values.appname }} + minReplicas: {{ .Values.hpa.min_pods }} + maxReplicas: {{ .Values.hpa.max_pods }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.hpa.cpu_target }} + behavior: + scaleDown: + stabilizationWindowSeconds: 60 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 0 + policies: + - type: Pods + value: 1 + periodSeconds: 15 +{{ end }} diff --git a/apps/mlflow-serve/chart/templates/ingress.yaml b/apps/mlflow-serve/chart/templates/ingress.yaml new file mode 100644 index 0000000..3485086 --- /dev/null +++ b/apps/mlflow-serve/chart/templates/ingress.yaml @@ -0,0 +1,63 @@ +{{ if .Values.ingress.v1beta1 }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + labels: + app: mlflow-serve + host: {{ .Release.Name }}.{{ .Values.global.domain }} + annotations: + nginx.ingress.kubernetes.io/proxy-connect-timeout: "600" + nginx.ingress.kubernetes.io/proxy-read-timeout: "600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "600" + 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/rewrite-target: /$1 + name: {{ .Release.Name }}-ingress + namespace: {{ .Values.namespace }} +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + serviceName: {{ .Release.Name }}-mlflow-svc + servicePort: 80 + tls: + - secretName: prod-ingress + hosts: + - {{ .Release.Name }}.{{ .Values.global.domain }} +{{ else }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + labels: + app: mlflow-serve + host: {{ .Release.Name }}.{{ .Values.global.domain }} + annotations: + nginx.ingress.kubernetes.io/proxy-connect-timeout: "600" + nginx.ingress.kubernetes.io/proxy-read-timeout: "600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "600" + 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/rewrite-target: /$1 + name: {{ .Release.Name }}-ingress + namespace: {{ .Values.namespace }} +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Release.Name }}-mlflow-svc + port: + number: 80 + pathType: ImplementationSpecific + tls: + - secretName: prod-ingress + hosts: + - {{ .Release.Name }}.{{ .Values.global.domain }} + +{{- end }} diff --git a/apps/mlflow-serve/chart/templates/nginx_conf.yaml b/apps/mlflow-serve/chart/templates/nginx_conf.yaml new file mode 100644 index 0000000..45da20d --- /dev/null +++ b/apps/mlflow-serve/chart/templates/nginx_conf.yaml @@ -0,0 +1,27 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-rp-config + namespace: {{ .Values.namespace }} +data: + nginx.conf: |- + pid /tmp/nginx.pid; + worker_processes 1; + events { worker_connections 1024; } + http { + server { + listen 1234; + + client_max_body_size 500M; + large_client_header_buffers 4 128k; + + location / { + proxy_pass http://127.0.0.1:{{ .Values.appconfig.port }}; + } + {{ if .Values.model_card.enabled }} + location ~ ^/model-card(/?)(.*) { + proxy_pass http://127.0.0.1:80/$2; + } + {{ end }} + } + } diff --git a/apps/mlflow-serve/chart/templates/nginx_model.yaml b/apps/mlflow-serve/chart/templates/nginx_model.yaml new file mode 100644 index 0000000..c19f7b1 --- /dev/null +++ b/apps/mlflow-serve/chart/templates/nginx_model.yaml @@ -0,0 +1,18 @@ +{{ if .Values.model_card.enabled }} +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-mc-config + namespace: {{ .Values.namespace }} +data: + # Configuration values can be set as key-value properties + nginx.conf: |- + worker_processes 1; + events { worker_connections 1024; } + http { + server { + listen 80; + root /model/{{ .Values.model_card.path }}; + } + } +{{ end }} diff --git a/apps/mlflow-serve/chart/templates/service.yaml b/apps/mlflow-serve/chart/templates/service.yaml new file mode 100644 index 0000000..2cbc0db --- /dev/null +++ b/apps/mlflow-serve/chart/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-mlflow-svc + namespace: {{ .Values.namespace }} + labels: + run: {{ .Values.appname }}-svc + app: {{ .Values.appname }} +spec: + ports: + - protocol: TCP + port: 80 + targetPort: {{ .Values.appconfig.port }} + selector: + release: {{ .Release.Name }} diff --git a/apps/mlflow-serve/chart/values.yaml b/apps/mlflow-serve/chart/values.yaml new file mode 100644 index 0000000..72fe735 --- /dev/null +++ b/apps/mlflow-serve/chart/values.yaml @@ -0,0 +1,60 @@ +replicas: 1 +appname: mlflow-serve + +visibility: private + + +global: + domain: global.domain + protocol: TCP + +project: + slug: project-slug + +appconfig: + image: ghcr.io/scilifelabdatacentre/serve-mlflow:231030-1149 + port: 5000 + + +context: + image: context-image + +hpa: + enabled: false + min_pods: 1 + max_pods: 3 + cpu_target: 60 + + +model: + name: name + version: version + release_type: release_type + description: short-description + url: url + access_key: key + secret_key: secret + bucket: bucket + obj: obj + +model_card: + enabled: false + path: model-card + +ingress: + v1beta1: false + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 100 + +securityContext: + runAsNonRoot: true + runAsUser: 101 + runAsGroup: 101 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all diff --git a/apps/mlflow-serve/config.json b/apps/mlflow-serve/config.json new file mode 100644 index 0000000..e778348 --- /dev/null +++ b/apps/mlflow-serve/config.json @@ -0,0 +1,52 @@ +{ + "category": "serve", + "description": "", + "name": "MLFlow Serve", + "priority": "400", + "settings": { + "default_values": { + "is_tar": "False", + "port": "5000", + "targetport": "8501" + }, + "env_variables": { + "{{ app_name }}_URL": "https://{{ release }}.{{ global.domain }}/invocation" + }, + "environment": { + "name": "from", + "quantity": "one", + "title": "Environment", + "type": "match" + }, + "flavor": "one", + "logs": [ + "serve" + ], + "model": { + "object_type": "mlflow", + "quantity": "one" + }, + "permissions": { + "link": { + "option": "false", + "value": "false" + }, + "private": { + "option": "true", + "value": "false" + }, + "project": { + "option": "true", + "value": "true" + }, + "public": { + "option": "true", + "value": "false" + } + } + }, + "slug": "mlflow-serve", + "table_field": { + "url": "https://{{ release }}.{{ global.domain }}/invocations" + } +} diff --git a/apps/mlflow-serve/logo.png b/apps/mlflow-serve/logo.png new file mode 100644 index 0000000..461f8a2 Binary files /dev/null and b/apps/mlflow-serve/logo.png differ diff --git a/apps/mlflow/chart/Chart.yaml b/apps/mlflow/chart/Chart.yaml new file mode 100644 index 0000000..62dacf9 --- /dev/null +++ b/apps/mlflow/chart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for MLFlow App +name: MLFlow +version: 0.0.1 diff --git a/apps/mlflow/chart/templates/deployment.yaml b/apps/mlflow/chart/templates/deployment.yaml new file mode 100644 index 0000000..4ce5365 --- /dev/null +++ b/apps/mlflow/chart/templates/deployment.yaml @@ -0,0 +1,105 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Values.namespace }} + annotations: + reloader.stakater.com/auto: "true" +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + release: {{ .Release.Name }} + app: {{ .Values.appname }} + project: {{ .Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + labels: + release: {{ .Release.Name }} + app: {{ .Values.appname }} + project: {{ .Values.project.slug }} + networking/allow-internet-egress: "false" + type: app + pod: {{ .Values.appname }} + spec: + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + initContainers: + - name: wait-for-s3 + image: busybox + env: + - name: S3_SERVICE + value: "{{ .Values.s3.service }}" + - name: S3_PORT + value: "{{ .Values.s3.port }}" + command: ["sh", "-c", "until nc -z $S3_SERVICE $S3_PORT > /dev/null; do echo Waiting for master.; sleep 2; done;"] + - name: create-bucket + image: minio/mc + env: + - name: S3_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: {{ .Values.s3.service }} + key: accesskey + - name: S3_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: {{ .Values.s3.service }} + key: secretkey + - name: S3_ENDPOINT + value: "http://{{ .Values.s3.service }}:{{ .Values.s3.port }}" + imagePullPolicy: IfNotPresent + command: ["/bin/bash"] + args: ["-c", "mc alias set projminio $S3_ENDPOINT $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;mc mb projminio/mlflow || echo 'Bucket mlflow already exists'"] + containers: + - image: {{ .Values.appconfig.image }} + imagePullPolicy: IfNotPresent + name: mlflow + command: ["/bin/bash"] + args: ["-c", "mlflow server --backend-store-uri $BACKEND_STORE_URI --default-artifact-root s3://$MLFLOW_BUCKET/ --host 0.0.0.0 --port 5000"] + ports: + - containerPort: {{ .Values.appconfig.port }} + env: + - name: BACKEND_STORE_URI + value: sqlite:///mlruns/mydb.sqlite + - name: MLFLOW_BUCKET + value: mlflow + - name: MLFLOW_S3_ENDPOINT_URL + value: "http://{{ .Values.s3.service }}:{{ .Values.s3.port }}" + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: {{ .Values.s3.service }} + key: accesskey + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: {{ .Values.s3.service }} + key: secretkey + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + volumeMounts: + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + mountPath: /mlruns + {{- end }} + hostname: {{ .Release.Name }} + restartPolicy: Always + volumes: + - name: auth-vol + emptyDir: {} + - name: rp-conf + configMap: + name: {{ .Release.Name }}-rp-config + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + persistentVolumeClaim: + claimName: {{ $value.release }} + {{- end }} diff --git a/apps/mlflow/chart/templates/ingress.yaml b/apps/mlflow/chart/templates/ingress.yaml new file mode 100644 index 0000000..6598f03 --- /dev/null +++ b/apps/mlflow/chart/templates/ingress.yaml @@ -0,0 +1,58 @@ +{{ if .Values.ingress.v1beta1 }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-mlflow-ingress + namespace: {{ .Values.namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + nginx.ingress.kubernetes.io/proxy-body-size: "5500m" + 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 +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + serviceName: {{ .Values.service.name }}-{{ .Values.app_name }} + servicePort: 80 + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Release.Name }}.{{ .Values.global.domain }} + +{{ else }} + +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress-server + namespace: {{ .Values.namespace }} + annotations: + nginx.ingress.kubernetes.io/proxy-body-size: "5500m" + 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 +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: 5000 + pathType: ImplementationSpecific + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Release.Name }}.{{ .Values.global.domain }} +apiVersion: networking.k8s.io/v1 + +{{- end }} diff --git a/apps/mlflow/chart/templates/service.yaml b/apps/mlflow/chart/templates/service.yaml new file mode 100644 index 0000000..c590267 --- /dev/null +++ b/apps/mlflow/chart/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }}-ui + namespace: {{ .Values.namespace }} + labels: + run: {{ .Release.Name }}-mlflow + app: mlflow-ui +spec: + ports: + - port: 80 + targetPort: {{ .Values.appconfig.uiport }} + protocol: TCP + selector: + release: {{ .Release.Name }} diff --git a/apps/mlflow/chart/templates/service_server.yaml b/apps/mlflow/chart/templates/service_server.yaml new file mode 100644 index 0000000..b7fc80a --- /dev/null +++ b/apps/mlflow/chart/templates/service_server.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Values.namespace }} + labels: + run: {{ .Release.Name }}-mlflow +spec: + ports: + - port: {{ .Values.appconfig.port }} + targetPort: {{ .Values.appconfig.port }} + protocol: TCP + selector: + release: {{ .Release.Name }} diff --git a/apps/mlflow/chart/values.yaml b/apps/mlflow/chart/values.yaml new file mode 100644 index 0000000..97fad01 --- /dev/null +++ b/apps/mlflow/chart/values.yaml @@ -0,0 +1,49 @@ + +appname: mlflow +project: + name: project + slug: project-slug + +global: + domain: localhost + +apps: + volumek8s: + +appconfig: + port: 5000 + uiport: 9090 + image: ghcr.io/scilifelabdatacentre/serve-mlflow:231030-1149 + +service: + name: mlflow-svc + +s3: + service: + port: + +imagePullSecrets: + - name: regcred + +ingress: + v1beta1: false + secretName: prod-ingress + +ingress: + v1beta1: false + secretName: prod-ingress + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all diff --git a/apps/mlflow/config.json b/apps/mlflow/config.json new file mode 100644 index 0000000..ed253dd --- /dev/null +++ b/apps/mlflow/config.json @@ -0,0 +1,49 @@ +{ + "category": "develop", + "description": "", + "name": "MLFlow", + "settings": { + "S3": "one", + "apps": { + "Persistent Volume": "one" + }, + "credentials": { + "password": { + "default": "password", + "title": "Password", + "type": "string" + }, + "username": { + "default": "admin", + "title": "Username", + "type": "string" + } + }, + "default_values": { + "port": "5000", + "targetport": "5000" + }, + "permissions": { + "link": { + "option": "false", + "value": "false" + }, + "private": { + "option": "true", + "value": "false" + }, + "project": { + "option": "true", + "value": "true" + }, + "public": { + "option": "false", + "value": "false" + } + } + }, + "slug": "mlflow", + "table_field": { + "url": "https://{{ release }}.{{ global.domain }}" + } +} diff --git a/apps/mlflow/logo.png b/apps/mlflow/logo.png new file mode 100644 index 0000000..461f8a2 Binary files /dev/null and b/apps/mlflow/logo.png differ diff --git a/apps/netpolicy/Chart.yaml b/apps/netpolicy/Chart.yaml new file mode 100644 index 0000000..0414360 --- /dev/null +++ b/apps/netpolicy/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for network policy +name: netpolicy +version: 1.0.0 +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/netpolicy/templates/default.yaml b/apps/netpolicy/templates/default.yaml new file mode 100644 index 0000000..875b4bf --- /dev/null +++ b/apps/netpolicy/templates/default.yaml @@ -0,0 +1,50 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ .Release.Name }}-allow-project-ingress + namespace: {{ .Release.Namespace }} +spec: + podSelector: + matchLabels: + project: {{ .Values.project.slug }} + policyTypes: + - Ingress + ingress: + - from: + - podSelector: + matchLabels: + project: {{ .Values.project.slug }} +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ .Release.Name }}-allow-ingress-from-studio + namespace: {{ .Release.Namespace }} +spec: + podSelector: + matchLabels: + project: {{ .Values.project.slug }} + policyTypes: + - Ingress + ingress: + - from: + - podSelector: + matchLabels: + app: stackn-studio +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ .Release.Name }}-allow-egress-to-project + namespace: {{ .Release.Namespace }} +spec: + podSelector: + matchLabels: + project: {{ .Values.project.slug }} + policyTypes: + - Egress + egress: + - to: + - podSelector: + matchLabels: + project: {{ .Values.project.slug }} diff --git a/apps/netpolicy/values.yaml b/apps/netpolicy/values.yaml new file mode 100644 index 0000000..d584fd4 --- /dev/null +++ b/apps/netpolicy/values.yaml @@ -0,0 +1,4 @@ +appname: netpolicy +project: + name: project + slug: project-slug diff --git a/apps/python-serve/chart/Chart.yaml b/apps/python-serve/chart/Chart.yaml new file mode 100644 index 0000000..1511a6a --- /dev/null +++ b/apps/python-serve/chart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for Python Model Deployment +name: python-model-deployment +version: 0.0.1 diff --git a/apps/python-serve/chart/templates/deployment.yaml b/apps/python-serve/chart/templates/deployment.yaml new file mode 100644 index 0000000..f35e023 --- /dev/null +++ b/apps/python-serve/chart/templates/deployment.yaml @@ -0,0 +1,86 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Values.namespace }} +spec: + replicas: 1 + selector: + matchLabels: + release: {{ .Release.Name }} + app: {{ .Values.appname }} + project: {{ .Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + prometheus.io/port: "8501" + labels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-egress-to-studio-web: "true" + type: app + pod: {{ .Values.appname }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + volumes: + - name: rp-conf + configMap: + name: {{ .Release.Name }}-rp-config + {{ if .Values.apps.volumeK8s }} + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: model-vol + persistentVolumeClaim: + claimName: {{ $value.release }} + {{- end }} + {{- end }} + containers: + - name: reverse-proxy + image: nginx:alpine + imagePullPolicy: IfNotPresent + volumeMounts: + - name: rp-conf + mountPath: /etc/nginx + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 128Mi + + - name: serve + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + volumeMounts: + - name: model-vol + mountPath: /home/user/models + env: + - name: GUNICORN_CMD_ARGS + value: "--limit-request-field_size 0" + {{- with .Values.extraEnv }} + {{- tpl . $ | nindent 10 }} + {{- end }} + - name: PYTHONPATH + value: "/home/user/models" + - name: STACKN_MODEL_PATH + value: "/home/user/models" + image: {{ .Values.environment.repository }}/{{ .Values.environment.image }} + imagePullPolicy: IfNotPresent + ports: + - containerPort: {{ .Values.appconfig.port }} + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst diff --git a/apps/python-serve/chart/templates/ingress.yaml b/apps/python-serve/chart/templates/ingress.yaml new file mode 100644 index 0000000..80e2a06 --- /dev/null +++ b/apps/python-serve/chart/templates/ingress.yaml @@ -0,0 +1,29 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Values.namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + nginx.ingress.kubernetes.io/proxy-body-size: 50m + {{ if and (ne .Values.permission "public") (ne .Values.permission "link") }} + 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 }} +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: {{ .Values.service.port }} + pathType: ImplementationSpecific + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Values.global.domain }} diff --git a/apps/python-serve/chart/templates/nginx_conf.yaml b/apps/python-serve/chart/templates/nginx_conf.yaml new file mode 100644 index 0000000..8bf7484 --- /dev/null +++ b/apps/python-serve/chart/templates/nginx_conf.yaml @@ -0,0 +1,22 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-rp-config + namespace: {{ .Values.namespace }} +data: + # Configuration values can be set as key-value properties + nginx.conf: |- + worker_processes 1; + events { worker_connections 1024; } + http { + server { + listen 1234; + + client_max_body_size 500M; + large_client_header_buffers 4 128k; + + location / { + proxy_pass http://127.0.0.1:{{ .Values.appconfig.port }}; + } + } + } diff --git a/apps/python-serve/chart/templates/service.yaml b/apps/python-serve/chart/templates/service.yaml new file mode 100644 index 0000000..cc8b0ad --- /dev/null +++ b/apps/python-serve/chart/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Values.namespace }} + labels: + run: {{ .Values.appname }}-python-serve +spec: + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.appconfig.port }} + protocol: TCP + selector: + release: {{ .Release.Name }} diff --git a/apps/python-serve/chart/values.yaml b/apps/python-serve/chart/values.yaml new file mode 100644 index 0000000..fbabd29 --- /dev/null +++ b/apps/python-serve/chart/values.yaml @@ -0,0 +1,38 @@ + +appname: python-serve +project: + name: project + slug: project-slug + +global: + protocol: TCP + +apps: + volumek8s: + +appconfig: + port: 8000 + +service: + name: pythonserve-svc + +imagePullSecrets: + - name: regcred + +ingress: + secretName: prod-ingress + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all diff --git a/apps/python-serve/config.json b/apps/python-serve/config.json new file mode 100644 index 0000000..d2d5f70 --- /dev/null +++ b/apps/python-serve/config.json @@ -0,0 +1,50 @@ +{ + "category": "serve", + "description": "", + "name": "Python Model Deployment", + "priority": "200", + "settings": { + "default_values": { + "port": "80", + "targetport": "8080" + }, + "env_variables": { + "{{ app_name }}_URL": "https://{{ release }}.{{ global.domain }}/predict/" + }, + "environment": { + "name": "from", + "quantity": "one", + "title": "Environment", + "type": "match" + }, + "flavor": "one", + "logs": [ + "serve" + ], + "model": { + "object_type": "python-model" + }, + "permissions": { + "link": { + "option": "true", + "value": "false" + }, + "private": { + "option": "true", + "value": "false" + }, + "project": { + "option": "true", + "value": "true" + }, + "public": { + "option": "true", + "value": "false" + } + } + }, + "slug": "python-serve", + "table_field": { + "url": "https://{{ release }}.{{ global.domain }}/predict/" + } +} diff --git a/apps/pytorch-serve/chart/Chart.yaml b/apps/pytorch-serve/chart/Chart.yaml new file mode 100644 index 0000000..e527f3a --- /dev/null +++ b/apps/pytorch-serve/chart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for PyTorch Serve Deployment +name: torchserve +version: 0.1.0 diff --git a/apps/pytorch-serve/chart/templates/deployment.yaml b/apps/pytorch-serve/chart/templates/deployment.yaml new file mode 100644 index 0000000..43f74e2 --- /dev/null +++ b/apps/pytorch-serve/chart/templates/deployment.yaml @@ -0,0 +1,114 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.release }} + namespace: {{ .Release.Namespace }} + annotations: + reloader.stakater.com/auto: "true" +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + prometheus.io/port: "8501" + labels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-internet-ingress: "true" + type: app + pod: {{ .Values.appname }} + spec: + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + initContainers: + - name: copy-model + image: minio/mc + imagePullPolicy: IfNotPresent + command: ["/bin/bash"] + {{ if .Values.s3.skip_tls }} + args: ["-c", "mc config host add --insecure projminio $S3_ENDPOINT $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;mc cp --insecure --recursive projminio/$MODEL_STORE/$STACKN_MODEL_FILE /home/model-server/model-store/"] + {{ else }} + args: ["-c", "mc config host add projminio $S3_ENDPOINT $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;mc cp --recursive projminio/$MODEL_STORE/$STACKN_MODEL_FILE /home/model-server/model-store/"] + {{ end }} + volumeMounts: + - name: model-vol + mountPath: /home/model-server/model-store/ + env: + - name: S3_ACCESS_KEY_ID + value: {{ .Values.model.access_key }} + - name: S3_SECRET_ACCESS_KEY + value: {{ .Values.model.secret_key }} + - name: S3_ENDPOINT + value: {{ .Values.model.url }} + - name: MODEL_STORE + value: {{ .Values.model.path }} + - name: STACKN_MODEL_FILE + value: {{ .Values.model.obj }} + - name: extract-model + image: busybox + imagePullPolicy: IfNotPresent + command: ["/bin/sh"] + args: ["-c", "cd /home/model-server/model-store && tar xvf $STACKN_MODEL_FILE && rm -v $STACKN_MODEL_FILE"] + volumeMounts: + - name: model-vol + mountPath: /home/model-server/model-store/ + env: + - name: MODEL_STORE + value: {{ .Values.model.path }} + - name: STACKN_MODEL_FILE + value: {{ .Values.model.obj }} + containers: + {{ if .Values.model_card.enabled }} + - name: model-card + image: nginx:alpine + imagePullPolicy: Always + volumeMounts: + - name: model-vol + mountPath: /models + - name: mc-conf + mountPath: /etc/nginx + {{ end }} + - name: pytorch-serve + image: {{ .Values.appconfig.image }} + command: ["torchserve", "--start", "--model-store", "/home/model-server/model-store/{{ .Values.model.path }}", "--models", "all", "--ts-config", "config.properties", "--foreground"] + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + volumeMounts: + - name: model-vol + mountPath: /home/model-server/model-store/ + imagePullPolicy: Always + ports: + - name: ts + containerPort: {{ .Values.appconfig.inference_port }} + - name: ts-management + containerPort: {{ .Values.appconfig.management_port }} + - name: ts-metrics + containerPort: {{ .Values.appconfig.metrics_port }} + volumes: + - name: torch-conf + configMap: + name: {{ .Release.Name }}-torch-conf + - name: rp-conf + configMap: + name: {{ .Release.Name }}-rp-config + {{ if .Values.model_card.enabled }} + - name: mc-conf + configMap: + name: {{ .Release.Name }}-mc-config + {{ end }} + - name: model-vol + emptyDir: {} diff --git a/apps/pytorch-serve/chart/templates/hpa.yaml b/apps/pytorch-serve/chart/templates/hpa.yaml new file mode 100644 index 0000000..f68c45d --- /dev/null +++ b/apps/pytorch-serve/chart/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{ if .Values.hpa.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Values.release }}-hpa + namespace: {{ .Release.Namespace }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Values.release }} + minReplicas: {{ .Values.hpa.min_pods }} + maxReplicas: {{ .Values.hpa.max_pods }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.hpa.cpu_target }} + behavior: + scaleDown: + stabilizationWindowSeconds: 60 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 0 + policies: + - type: Pods + value: 1 + periodSeconds: 15 +{{ end }} diff --git a/apps/pytorch-serve/chart/templates/ingress.yaml b/apps/pytorch-serve/chart/templates/ingress.yaml new file mode 100644 index 0000000..208c542 --- /dev/null +++ b/apps/pytorch-serve/chart/templates/ingress.yaml @@ -0,0 +1,44 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + nginx.ingress.kubernetes.io/proxy-connect-timeout: "600" + nginx.ingress.kubernetes.io/proxy-read-timeout: "600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "600" + nginx.ingress.kubernetes.io/proxy-body-size: "500m" + {{ if and (ne .Values.permission "public") (ne .Values.permission "link") }} + 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 }} + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: /predictions + backend: + service: + name: {{ $.Release.Name }}-pytorch-svc + port: + number: 8080 + pathType: ImplementationSpecific + - path: /models + backend: + service: + name: {{ $.Release.Name }}-pytorch-svc + port: + number: 8081 + pathType: ImplementationSpecific + - path: /metrics + backend: + service: + name: {{ $.Release.Name }}-pytorch-svc + port: + number: 8082 + pathType: ImplementationSpecific + tls: + - secretName: prod-ingress + hosts: + - {{ .Release.Name }}.{{ .Values.global.domain }} diff --git a/apps/pytorch-serve/chart/templates/nginx_conf.yaml b/apps/pytorch-serve/chart/templates/nginx_conf.yaml new file mode 100644 index 0000000..00f8746 --- /dev/null +++ b/apps/pytorch-serve/chart/templates/nginx_conf.yaml @@ -0,0 +1,26 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-rp-config + namespace: {{ .Release.Namespace }} +data: + # Configuration values can be set as key-value properties + nginx.conf: |- + pid /tmp/nginx.pid; + worker_processes 1; + events { worker_connections 1024; } + http { + server { + listen 1234; + client_max_body_size 500M; + + location / { + proxy_pass http://127.0.0.1:{{ .Values.appconfig.port }}; + } + {{ if .Values.model_card.enabled }} + location ~ ^/model-card(/?)(.*) { + proxy_pass http://127.0.0.1:80/$2; + } + {{ end }} + } + } diff --git a/apps/pytorch-serve/chart/templates/nginx_model.yaml b/apps/pytorch-serve/chart/templates/nginx_model.yaml new file mode 100644 index 0000000..7053a68 --- /dev/null +++ b/apps/pytorch-serve/chart/templates/nginx_model.yaml @@ -0,0 +1,18 @@ +{{ if .Values.model_card.enabled }} +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-mc-config + namespace: {{ .Release.Namespace }} +data: + # Configuration values can be set as key-value properties + nginx.conf: |- + worker_processes 1; + events { worker_connections 1024; } + http { + server { + listen 80; + root /model/{{ .Values.model_card.path }}; + } + } +{{ end }} diff --git a/apps/pytorch-serve/chart/templates/service.yaml b/apps/pytorch-serve/chart/templates/service.yaml new file mode 100644 index 0000000..d6f455a --- /dev/null +++ b/apps/pytorch-serve/chart/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ $.Release.Name }}-pytorch-svc + namespace: {{ .Release.Namespace }} +spec: + ports: + - name: preds + port: {{ .Values.appconfig.inference_port }} + targetPort: ts + - name: mdl + port: {{ .Values.appconfig.management_port }} + targetPort: ts-management + - name: metrics + port: {{ .Values.appconfig.metrics_port }} + targetPort: ts-metrics + selector: + release: {{ $.Release.Name }} diff --git a/apps/pytorch-serve/chart/templates/torch-config.yaml b/apps/pytorch-serve/chart/templates/torch-config.yaml new file mode 100644 index 0000000..30df128 --- /dev/null +++ b/apps/pytorch-serve/chart/templates/torch-config.yaml @@ -0,0 +1,14 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-torch-conf + namespace: {{ .Release.Namespace }} +data: + # Configuration values can be set as key-value properties + config.properties: |- + inference_address=http://0.0.0.0:8080 + management_address=http://0.0.0.0:8081 + metrics_address=http://0.0.0.0:8082 + number_of_netty_threads=32 + job_queue_size=1000 + model_store=/home/model-server/model-store diff --git a/apps/pytorch-serve/chart/values.yaml b/apps/pytorch-serve/chart/values.yaml new file mode 100644 index 0000000..033bdfc --- /dev/null +++ b/apps/pytorch-serve/chart/values.yaml @@ -0,0 +1,63 @@ +replicas: 1 +appname: pytorch-serve + +visibility: private + +global: + protocol: TCP + +project: + slug: project-slug + +appconfig: + image: ghcr.io/scilifelabdatacentre/serve-torchserve:231030-1146 + inference_port: 8080 + management_port: 8081 + metrics_port: 8082 + +context: + image: context-image + +hpa: + enabled: false + min_pods: 1 + max_pods: 3 + cpu_target: 60 + +s3: + skip_tls: true + +model: + name: name + version: version + release_type: release_type + description: short-description + url: url + access_key: key + secret_key: secret + bucket: bucket + obj: obj + +model_card: + enabled: false + path: model-card + +imagePullSecrets: + - name: regcred + +ingress: + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all diff --git a/apps/pytorch-serve/config.json b/apps/pytorch-serve/config.json new file mode 100644 index 0000000..2c50230 --- /dev/null +++ b/apps/pytorch-serve/config.json @@ -0,0 +1,44 @@ +{ + "category": "serve", + "description": "", + "name": "PyTorch Serve", + "priority": "500", + "settings": { + "default_values": { + "port": "80", + "targetport": "8080" + }, + "env_variables": { + "{{ app_name }}_URL": "https://{{ release }}.{{ global.domain }}/predictions/" + }, + "flavor": "one", + "logs": [ + "serve" + ], + "model": { + "object_type": "pytorch" + }, + "permissions": { + "link": { + "option": "true", + "value": "false" + }, + "private": { + "option": "true", + "value": "false" + }, + "project": { + "option": "true", + "value": "true" + }, + "public": { + "option": "true", + "value": "false" + } + } + }, + "slug": "torch-serve", + "table_field": { + "url": "https://{{ release }}.{{ global.domain }}/predictions/" + } +} diff --git a/apps/pytorch-serve/logo.png b/apps/pytorch-serve/logo.png new file mode 100644 index 0000000..bad49bf Binary files /dev/null and b/apps/pytorch-serve/logo.png differ diff --git a/apps/rstudio/Chart.yaml b/apps/rstudio/Chart.yaml new file mode 100644 index 0000000..c2bc188 --- /dev/null +++ b/apps/rstudio/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for RStudio in the browser +name: rstudio +version: 1.0.1 +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/rstudio/templates/deployment.yaml b/apps/rstudio/templates/deployment.yaml new file mode 100644 index 0000000..e07895e --- /dev/null +++ b/apps/rstudio/templates/deployment.yaml @@ -0,0 +1,59 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Release.Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + # prometheus.io/port: "8501" + labels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-egress-to-studio-web: "true" + type: app + pod: {{ .Values.appname }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: rstudio + image: {{ .Values.appconfig.image }} + imagePullPolicy: IfNotPresent + ports: + - containerPort: {{ .Values.appconfig.port }} + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + volumeMounts: + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + mountPath: /home/jovyan/{{ $key }} + {{- end }} + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + volumes: + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + persistentVolumeClaim: + claimName: {{ $value.release }} + {{- end }} diff --git a/apps/rstudio/templates/ingress.yaml b/apps/rstudio/templates/ingress.yaml new file mode 100644 index 0000000..a1d01bf --- /dev/null +++ b/apps/rstudio/templates/ingress.yaml @@ -0,0 +1,54 @@ +{{ if .Values.ingress.v1beta1 }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + 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 +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + serviceName: {{ .Values.service.name }} + servicePort: {{ .Values.service.port }} + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Values.global.domain }} +{{ else }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + 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 +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: {{ .Values.service.port }} + pathType: ImplementationSpecific + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Values.global.domain }} +{{- end }} diff --git a/apps/rstudio/templates/service.yaml b/apps/rstudio/templates/service.yaml new file mode 100644 index 0000000..040e3f7 --- /dev/null +++ b/apps/rstudio/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Release.Namespace }} + labels: + run: {{ .Release.Name }}-rstudio +spec: + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetport }} + selector: + release: {{ $.Release.Name }} diff --git a/apps/rstudio/values.yaml b/apps/rstudio/values.yaml new file mode 100644 index 0000000..e3beb34 --- /dev/null +++ b/apps/rstudio/values.yaml @@ -0,0 +1,42 @@ +appname: rstudio +project: + name: project + slug: project-slug + +global: + protocol: TCP + domain: studio.127.0.0.1.nip.io + auth_domain: studio.127.0.0.1.nip.io + +apps: + volumek8s: + +appconfig: + port: 8787 + image: ghcr.io/scilifelabdatacentre/serve-rstudio:231030-1146 + +service: + name: rstudio-svc + port: 80 + +imagePullSecrets: + - name: regcred + +ingress: + v1beta1: false + secretName: prod-ingress + +podSecurityContext: + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all + +flavor: {} diff --git a/apps/shiny/Chart.yaml b/apps/shiny/Chart.yaml new file mode 100644 index 0000000..0f0ec5d --- /dev/null +++ b/apps/shiny/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart Shiny apps +name: shinyapp +version: 1.0.1 +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/shiny/templates/deployment.yaml b/apps/shiny/templates/deployment.yaml new file mode 100644 index 0000000..95737f0 --- /dev/null +++ b/apps/shiny/templates/deployment.yaml @@ -0,0 +1,48 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Release.Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + # prometheus.io/port: "8501" + labels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-egress-to-studio-web: "true" + type: app + pod: {{ .Values.appname }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Values.appname }} + image: {{ .Values.appconfig.image }} + imagePullPolicy: IfNotPresent + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + ports: + - containerPort: {{ .Values.appconfig.port }} + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst diff --git a/apps/shiny/templates/ingress.yaml b/apps/shiny/templates/ingress.yaml new file mode 100644 index 0000000..1dc5e65 --- /dev/null +++ b/apps/shiny/templates/ingress.yaml @@ -0,0 +1,28 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + {{ if and (ne .Values.permission "public") (ne .Values.permission "link") }} + 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 }} +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: {{ .Values.service.port }} + pathType: ImplementationSpecific + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Values.global.domain }} diff --git a/apps/shiny/templates/service.yaml b/apps/shiny/templates/service.yaml new file mode 100644 index 0000000..ed6cb09 --- /dev/null +++ b/apps/shiny/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Release.Namespace }} + labels: + run: {{ .Release.Name }}-shinyapp +spec: + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.appconfig.port }} + selector: + release: {{ $.Release.Name }} diff --git a/apps/shiny/values.yaml b/apps/shiny/values.yaml new file mode 100644 index 0000000..49a507c --- /dev/null +++ b/apps/shiny/values.yaml @@ -0,0 +1,41 @@ +appname: shinyapp +project: + name: project + slug: project-slug + +global: + protocol: TCP + domain: studio.127.0.0.1.nip.io + auth_domain: studio.127.0.0.1.nip.io + +apps: + volumek8s: + +appconfig: + port: 8501 + image: ghcr.io/scilifelabdatacentre/shiny-adhd-medication-sweden:20240117-062031 + +service: + name: shiny-svc + port: 80 + +imagePullSecrets: + - name: regcred + +ingress: + secretName: prod-ingress + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 999 + runAsGroup: 999 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all diff --git a/apps/shinyproxy/Chart.yaml b/apps/shinyproxy/Chart.yaml new file mode 100644 index 0000000..884b1fb --- /dev/null +++ b/apps/shinyproxy/Chart.yaml @@ -0,0 +1,9 @@ +apiVersion: v2 +name: shinyproxy +description: A Helm chart to install Shinyproxy +type: application +version: 1.0.0 +appVersion: "0.1" +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/shinyproxy/templates/_helpers.tpl b/apps/shinyproxy/templates/_helpers.tpl new file mode 100644 index 0000000..f014fc8 --- /dev/null +++ b/apps/shinyproxy/templates/_helpers.tpl @@ -0,0 +1,71 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "shinyproxy.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "shinyproxy.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "shinyproxy.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "shinyproxy.labels" -}} +helm.sh/chart: {{ include "shinyproxy.chart" . }} +{{ include "shinyproxy.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "shinyproxy.selectorLabels" -}} +app.kubernetes.io/name: {{ include "shinyproxy.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "shinyproxy.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "shinyproxy.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{- define "shinyproxy.resourcename" -}} +{{- if .Values.useReleaseName }} +{{- printf "%s" (include "shinyproxy.fullname" .) }} +{{- else }} +{{- printf "%s" "shinyproxy" }} +{{- end }} +{{- end }} diff --git a/apps/shinyproxy/templates/configmap.yaml b/apps/shinyproxy/templates/configmap.yaml new file mode 100644 index 0000000..e1c2842 --- /dev/null +++ b/apps/shinyproxy/templates/configmap.yaml @@ -0,0 +1,55 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-shinyproxy-configmap + labels: + {{- include "shinyproxy.labels" . | nindent 4 }} +data: + application.yml: | + management: + server: + port: 9091 + server: + secure-cookies: true + proxy: + authentication: none + container-backend: kubernetes + heartbeat-rate: 10000 + heartbeat-timeout: 60000 + kubernetes: + internal-networking: true + namespace: {{ .Release.Namespace }} + image-pull-policy: IfNotPresent + hide-navbar: true + landing-page: /app/{{ .Release.Name }} + livenessProbe: {} + logo-url: https://www.openanalytics.eu/shinyproxy/logo.png + port: {{ .Values.appconfig.proxyport }} + readinessProbe: {} + same-site-cookie: None + specs: + - container-cmd: + - /usr/bin/shiny-server + container-cpu-limit: {{ .Values.flavor.limits.cpu }} + container-cpu-request: {{ .Values.flavor.requests.cpu }} + container-image: {{ .Values.appconfig.image }} + container-memory-limit: {{ .Values.flavor.limits.memory }} + container-memory-request: {{ .Values.flavor.requests.memory }} + port: {{ .Values.appconfig.port }} + id: {{ .Release.Name }} + display-name: {{ .Values.app_name }} + description: {{ .Values.app_description }} + labels: + sp.instance: {{ .Release.Name }} + allow-internet-egress: "true" + shinyproxy-app: {{ .Release.Name }} + kubernetes-pod-patches: | + - op: add + path: /spec/securityContext + value: + runAsUser: 999 + runAsGroup: 999 + runAsNonRoot: true + allowPrivilegeEscalation: false + privileged: false + title: Serve Shiny Proxy diff --git a/apps/shinyproxy/templates/deployment.yaml b/apps/shinyproxy/templates/deployment.yaml new file mode 100644 index 0000000..56937ad --- /dev/null +++ b/apps/shinyproxy/templates/deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Release.Namespace }} + annotations: + reloader.stakater.com/auto: "true" +spec: + replicas: 1 + selector: + matchLabels: + release: {{ .Release.Name }} + app: shinyproxy-deployment + project: {{ .Values.project.slug }} + type: app + pod: serve + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + # prometheus.io/port: "8501" + labels: + release: {{ .Release.Name }} + app: shinyproxy-deployment + project: {{ .Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-egress-to-studio-web: "true" + allow-api-access: "true" + type: app + pod: serve + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + serviceAccountName: {{ .Release.Namespace }}-shinyproxy + containers: + - name: serve + image: {{ .Values.appconfig.proxyimage }} + ports: + - containerPort: {{ .Values.appconfig.proxyport }} + volumeMounts: + - name: application-conf-{{ .Release.Name }} + mountPath: /opt/shinyproxy/config + imagePullPolicy: IfNotPresent + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + limits: + cpu: 300m + memory: 800Mi + requests: + cpu: 200m + memory: 512Mi + readinessProbe: + tcpSocket: + port: {{ .Values.appconfig.proxyport }} + initialDelaySeconds: 60 + periodSeconds: 15 + volumes: + - name: application-conf-{{ .Release.Name }} + configMap: + name: {{ .Release.Name }}-shinyproxy-configmap + dnsPolicy: ClusterFirst diff --git a/apps/shinyproxy/templates/hooks.yaml b/apps/shinyproxy/templates/hooks.yaml new file mode 100644 index 0000000..8b02049 --- /dev/null +++ b/apps/shinyproxy/templates/hooks.yaml @@ -0,0 +1,30 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: "delete-user-pods-{{ .Release.Name }}" + labels: + {{- include "shinyproxy.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": pre-delete + "helm.sh/hook-weight": "-5" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: "delete-user-pods-{{ .Release.Name }}" + labels: + {{- include "shinyproxy.labels" . | nindent 8 }} + allow-api-access: "true" + spec: + restartPolicy: Never + serviceAccountName: {{ .Release.Namespace }}-shinyproxy + containers: + - name: delete-user-pods + image: bitnami/kubectl:{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }} + args: + - "delete" + - "pods" + - "-l" + - "sp.instance={{ .Release.Name }}" + - "-n" + - "{{ .Release.Namespace }}" diff --git a/apps/shinyproxy/templates/ingress.yaml b/apps/shinyproxy/templates/ingress.yaml new file mode 100644 index 0000000..90f1501 --- /dev/null +++ b/apps/shinyproxy/templates/ingress.yaml @@ -0,0 +1,30 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + {{ if and (ne .Values.permission "public") (ne .Values.permission "link") }} + 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/proxy-body-size: 2000m + #nginx.ingress.kubernetes.io/auth-response-headers: X-Forwarded-Host +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: 80 + pathType: ImplementationSpecific + tls: + - secretName: prod-ingress + hosts: + - {{ .Values.global.domain }} diff --git a/apps/shinyproxy/templates/service.yaml b/apps/shinyproxy/templates/service.yaml new file mode 100644 index 0000000..e6b36f4 --- /dev/null +++ b/apps/shinyproxy/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Release.Namespace }} + labels: + run: {{ .Release.Name }}-shinyapp +spec: + ports: + - protocol: TCP + port: 80 + targetPort: {{ .Values.appconfig.proxyport }} + selector: + release: {{ $.Release.Name }} diff --git a/apps/shinyproxy/values.yaml b/apps/shinyproxy/values.yaml new file mode 100644 index 0000000..8d3993a --- /dev/null +++ b/apps/shinyproxy/values.yaml @@ -0,0 +1,48 @@ +appname: shinyapp +project: + name: project + slug: project-slug + +appconfig: + proxyimage: ghcr.io/scilifelabdatacentre/serve-shinyproxy:231124-2126 + proxyport: 8080 + port: 3838 + image: + + +global: + domain: localhost + +service: + name: shinyproxy-svc + +ingress: + secretName: prod-ingress + +s3sync: + image: scaleoutsystems/s3-sync:latest + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all + +flavor: + limits: + cpu: 1 + ephemeral-storage: 800Mi + memory: 1Gi + requests: + cpu: 500m + ephemeral-storage: 500Mi + memory: 500Mi diff --git a/apps/tensorflow-serve/chart/Chart.yaml b/apps/tensorflow-serve/chart/Chart.yaml new file mode 100644 index 0000000..137e8b8 --- /dev/null +++ b/apps/tensorflow-serve/chart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for Scaleout Tensorflow Serving Deployment +name: tensorflow serving +version: 0.1.0 diff --git a/apps/tensorflow-serve/chart/templates/deployment.yaml b/apps/tensorflow-serve/chart/templates/deployment.yaml new file mode 100644 index 0000000..4e3a36e --- /dev/null +++ b/apps/tensorflow-serve/chart/templates/deployment.yaml @@ -0,0 +1,100 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Values.namespace }} + annotations: + reloader.stakater.com/auto: "true" +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + prometheus.io/port: "8501" + labels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-internet-ingress: "true" + type: app + pod: {{ .Values.appname }} + spec: + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + initContainers: + - name: copy-model + image: minio/mc + imagePullPolicy: IfNotPresent + command: ["/bin/bash"] + {{ if .Values.s3.skip_tls }} + args: ["-c", "mc config host add --insecure projminio $S3_ENDPOINT $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;mc cp --insecure projminio/$STACKN_MODEL_BUCKET/$STACKN_MODEL_FILE /models/model.tar.gz"] + {{ else }} + args: ["-c", "mc config host add projminio $S3_ENDPOINT $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;mc cp projminio/$STACKN_MODEL_BUCKET/$STACKN_MODEL_FILE /models/model.tar.gz"] + {{ end }} + volumeMounts: + - name: model-vol + mountPath: /models + env: + - name: S3_ACCESS_KEY_ID + value: {{ .Values.model.access_key }} + - name: S3_SECRET_ACCESS_KEY + value: {{ .Values.model.secret_key }} + - name: S3_ENDPOINT + value: {{ .Values.model.url }} + - name: STACKN_MODEL_BUCKET + value: {{ .Values.model.bucket }} + - name: STACKN_MODEL_FILE + value: {{ .Values.model.obj }} + - name: extract-model + image: busybox + imagePullPolicy: IfNotPresent + command: ["/bin/sh"] + args: ["-c", "cd /models && tar xvf model.tar.gz"] + volumeMounts: + - name: model-vol + mountPath: /models + containers: + {{ if .Values.model_card.enabled }} + - name: model-card + image: nginx:alpine + imagePullPolicy: IfNotPresent + volumeMounts: + - name: model-vol + mountPath: /models + - name: mc-conf + mountPath: /etc/nginx + {{ end }} + - name: serve + image: {{ .Values.appconfig.image }} + imagePullPolicy: IfNotPresent + ports: + - containerPort: {{ .Values.appconfig.port }} + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + volumeMounts: + - name: model-vol + mountPath: /models + env: + - name: MODEL_NAME + value: models + volumes: + {{ if .Values.model_card.enabled }} + - name: mc-conf + configMap: + name: {{ .Release.Name }}-mc-config + {{ end }} + - name: model-vol + emptyDir: {} diff --git a/apps/tensorflow-serve/chart/templates/hpa.yaml b/apps/tensorflow-serve/chart/templates/hpa.yaml new file mode 100644 index 0000000..98ca7eb --- /dev/null +++ b/apps/tensorflow-serve/chart/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{ if .Values.hpa.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Values.appname }}-hpa + namespace: {{ .Values.namespace }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Values.appname }} + minReplicas: {{ .Values.hpa.min_pods }} + maxReplicas: {{ .Values.hpa.max_pods }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.hpa.cpu_target }} + behavior: + scaleDown: + stabilizationWindowSeconds: 60 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 0 + policies: + - type: Pods + value: 1 + periodSeconds: 15 +{{ end }} diff --git a/apps/tensorflow-serve/chart/templates/ingress.yaml b/apps/tensorflow-serve/chart/templates/ingress.yaml new file mode 100644 index 0000000..df32054 --- /dev/null +++ b/apps/tensorflow-serve/chart/templates/ingress.yaml @@ -0,0 +1,33 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + labels: + app: tensorflow-serving + host: {{ .Release.Name }}.{{ .Values.global.domain }} + annotations: + nginx.ingress.kubernetes.io/proxy-connect-timeout: "600" + nginx.ingress.kubernetes.io/proxy-read-timeout: "600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "600" + nginx.ingress.kubernetes.io/proxy-body-size: "500m" + {{ if and (ne .Values.permission "public") (ne .Values.permission "link") }} + 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 }} + name: {{ .Release.Name }}-ingress + namespace: {{ .Values.namespace }} +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ $.Release.Name }}-tf-svc + port: + number: 80 + pathType: ImplementationSpecific + tls: + - secretName: prod-ingress + hosts: + - {{ .Release.Name }}.{{ .Values.global.domain }} diff --git a/apps/tensorflow-serve/chart/templates/nginx_conf.yaml b/apps/tensorflow-serve/chart/templates/nginx_conf.yaml new file mode 100644 index 0000000..a62636e --- /dev/null +++ b/apps/tensorflow-serve/chart/templates/nginx_conf.yaml @@ -0,0 +1,27 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-rp-config + namespace: {{ .Values.namespace }} +data: + # Configuration values can be set as key-value properties + nginx.conf: |- + pid /tmp/nginx.pid; + worker_processes 1; + events { worker_connections 1024; } + http { + server { + listen 1234; + client_max_body_size 500M; + large_client_header_buffers 4 128k; + + location / { + proxy_pass http://127.0.0.1:{{ .Values.appconfig.port }}; + } + {{ if .Values.model_card.enabled }} + location ~ ^/model-card(/?)(.*) { + proxy_pass http://127.0.0.1:80/$2; + } + {{ end }} + } + } diff --git a/apps/tensorflow-serve/chart/templates/nginx_model.yaml b/apps/tensorflow-serve/chart/templates/nginx_model.yaml new file mode 100644 index 0000000..c19f7b1 --- /dev/null +++ b/apps/tensorflow-serve/chart/templates/nginx_model.yaml @@ -0,0 +1,18 @@ +{{ if .Values.model_card.enabled }} +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-mc-config + namespace: {{ .Values.namespace }} +data: + # Configuration values can be set as key-value properties + nginx.conf: |- + worker_processes 1; + events { worker_connections 1024; } + http { + server { + listen 80; + root /model/{{ .Values.model_card.path }}; + } + } +{{ end }} diff --git a/apps/tensorflow-serve/chart/templates/service.yaml b/apps/tensorflow-serve/chart/templates/service.yaml new file mode 100644 index 0000000..73ff76a --- /dev/null +++ b/apps/tensorflow-serve/chart/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ $.Release.Name }}-tf-svc + namespace: {{ .Values.namespace }} + labels: + run: {{ .Values.appname }} + app: tensorflow-serve +spec: + ports: + - protocol: TCP + port: 80 + targetPort: 8501 + selector: + release: {{ $.Release.Name }} diff --git a/apps/tensorflow-serve/chart/values.yaml b/apps/tensorflow-serve/chart/values.yaml new file mode 100644 index 0000000..87fb906 --- /dev/null +++ b/apps/tensorflow-serve/chart/values.yaml @@ -0,0 +1,61 @@ +replicas: 1 +appname: tensorflow-serving + +visibility: private + +global: + protocol: TCP + +project: + slug: project-slug + +appconfig: + image: ghcr.io/scilifelabdatacentre/serve-tensorflow:231030-1148 + port: 8501 + +context: + image: context-image + +hpa: + enabled: false + min_pods: 1 + max_pods: 3 + cpu_target: 60 + +model: + name: name + version: version + release_type: release_type + description: short-description + url: url + access_key: key + secret_key: secret + bucket: bucket + obj: obj + +s3: + skip_tls: true + +model_card: + enabled: false + path: model-card + +imagePullSecrets: + - name: regcred + +ingress: + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all diff --git a/apps/tensorflow-serve/config.json b/apps/tensorflow-serve/config.json new file mode 100644 index 0000000..b57be09 --- /dev/null +++ b/apps/tensorflow-serve/config.json @@ -0,0 +1,45 @@ +{ + "category": "serve", + "description": "", + "name": "Tensorflow Serving", + "priority": "600", + "settings": { + "default_values": { + "port": "80", + "targetport": "8501" + }, + "env_variables": { + "{{ app_name }}_URL": "https://{{ release }}.{{ global.domain }}/v1/models/models:predict" + }, + "flavor": "one", + "logs": [ + "serve" + ], + "model": { + "object_type": "tensorflow" + }, + "permissions": { + "link": { + "option": "true", + "value": "false" + }, + "private": { + "option": "true", + "value": "false" + }, + "project": { + "option": "true", + "value": "true" + }, + "public": { + "option": "true", + "value": "false" + } + }, + "publishable": "true" + }, + "slug": "tensorflow-serving", + "table_field": { + "url": "https://{{ release }}.{{ global.domain }}/v1/models/models:predict" + } +} diff --git a/apps/tensorflow-serve/logo.png b/apps/tensorflow-serve/logo.png new file mode 100644 index 0000000..f1c6271 Binary files /dev/null and b/apps/tensorflow-serve/logo.png differ diff --git a/apps/tissuumaps/Chart.yaml b/apps/tissuumaps/Chart.yaml new file mode 100644 index 0000000..a5e271b --- /dev/null +++ b/apps/tissuumaps/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart tissuumaps apps +name: tissuumaps +version: 1.0.1 +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/tissuumaps/templates/deployment.yaml b/apps/tissuumaps/templates/deployment.yaml new file mode 100644 index 0000000..80ab621 --- /dev/null +++ b/apps/tissuumaps/templates/deployment.yaml @@ -0,0 +1,77 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Release.Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + # prometheus.io/port: "8501" + labels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-egress-to-studio-web: "true" + type: app + pod: {{ .Values.appname }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Values.appname }} + image: {{ .Values.appconfig.image }} + imagePullPolicy: Always + ports: + - containerPort: {{ .Values.service.targetport }} + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + + volumeMounts: + {{- if .Values.apps.volumeK8s }} + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + mountPath: {{ $.Values.appconfig.path }} + {{- end }} + {{- end }} + - name: tmp-empty + mountPath: /tmp + - name: {{ .Release.Name }}-tissuumaps-configmap + mountPath: /tissuumaps.cfg + subPath: tissuumaps.cfg + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + volumes: + {{- if .Values.apps.volumeK8s }} + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + persistentVolumeClaim: + claimName: {{ $value.release }} + {{- end }} + {{- end }} + - name: tmp-empty + emptyDir: {} + - name: {{ .Release.Name }}-tissuumaps-configmap + configMap: + name: {{ .Release.Name }}-tissuumaps-configmap + items: + - key: tissuumaps.cfg + path: tissuumaps.cfg diff --git a/apps/tissuumaps/templates/ingress.yaml b/apps/tissuumaps/templates/ingress.yaml new file mode 100644 index 0000000..1dc5e65 --- /dev/null +++ b/apps/tissuumaps/templates/ingress.yaml @@ -0,0 +1,28 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + {{ if and (ne .Values.permission "public") (ne .Values.permission "link") }} + 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 }} +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: {{ .Values.service.port }} + pathType: ImplementationSpecific + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Values.global.domain }} diff --git a/apps/tissuumaps/templates/service.yaml b/apps/tissuumaps/templates/service.yaml new file mode 100644 index 0000000..d1cf8d9 --- /dev/null +++ b/apps/tissuumaps/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Release.Namespace }} + labels: + run: {{ .Release.Name }}-tissuumaps +spec: + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetport }} + selector: + release: {{ $.Release.Name }} diff --git a/apps/tissuumaps/templates/tissuumaps-configmap.yaml b/apps/tissuumaps/templates/tissuumaps-configmap.yaml new file mode 100644 index 0000000..f1b6371 --- /dev/null +++ b/apps/tissuumaps/templates/tissuumaps-configmap.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-tissuumaps-configmap + namespace: {{ .Release.Namespace }} +data: + tissuumaps.cfg: |- + READ_ONLY = True + PLUGIN_FOLDER = "/mnt/data/plugins/" + SLIDE_DIR = "/mnt/data/tissuumaps-shared/" + DEFAULT_PROJECT = "project.tmap" + COLLAPSE_TOP_MENU = True + PROJECT_LIST = True diff --git a/apps/tissuumaps/values.yaml b/apps/tissuumaps/values.yaml new file mode 100644 index 0000000..d84c914 --- /dev/null +++ b/apps/tissuumaps/values.yaml @@ -0,0 +1,45 @@ +appname: tissuumaps +project: + name: project + slug: project-slug + +global: + protocol: TCP + domain: studio.127.0.0.1.nip.io + auth_domain: studio.127.0.0.1.nip.io + + +apps: + volumeK8s: + +appconfig: + image: docker.io/cavenel/tissuumaps:3 + path: /mnt/data/ + +service: + name: tissuumaps-svc + targetport: 80 + port: 80 + +imagePullSecrets: + - name: regcred + +ingress: + secretName: prod-ingress + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all + +flavor: {} diff --git a/apps/volumek8s/Chart.yaml b/apps/volumek8s/Chart.yaml new file mode 100644 index 0000000..0b5263a --- /dev/null +++ b/apps/volumek8s/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for Volumes +name: volumek8s +version: 1.0.0 +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/volumek8s/templates/pvc.yaml b/apps/volumek8s/templates/pvc.yaml new file mode 100644 index 0000000..e821a40 --- /dev/null +++ b/apps/volumek8s/templates/pvc.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }} + namespace: {{ .Release.Namespace }} +spec: + accessModes: + - {{ .Values.volume.accessModes }} + {{ if .Values.volume.storageClass }} + storageClassName: {{ .Values.volume.storageClass }} + {{ end }} + resources: + requests: + storage: {{ .Values.volume.size }} +status: {} diff --git a/apps/volumek8s/values.yaml b/apps/volumek8s/values.yaml new file mode 100644 index 0000000..c29e83d --- /dev/null +++ b/apps/volumek8s/values.yaml @@ -0,0 +1,12 @@ +accessModes: ReadWriteMany +storageClass: default + +appname: volumek8s +project: + name: project + slug: project-slug + +volume: + size: 10Mi + storageClass: false + accessModes: ReadWriteMany diff --git a/apps/vscode/Chart.yaml b/apps/vscode/Chart.yaml new file mode 100644 index 0000000..20035f5 --- /dev/null +++ b/apps/vscode/Chart.yaml @@ -0,0 +1,9 @@ +# https://github.com/coder/code-server +apiVersion: v1 +appVersion: "0.1" +description: A Helm chart for VS code in the browser +name: vscode +version: 1.0.0 +maintainers: + - name: Team Whale + email: serve@scilifelab.se diff --git a/apps/vscode/templates/deployment.yaml b/apps/vscode/templates/deployment.yaml new file mode 100644 index 0000000..3b4da30 --- /dev/null +++ b/apps/vscode/templates/deployment.yaml @@ -0,0 +1,67 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.appname }} + namespace: {{ .Release.Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + type: app + pod: {{ .Values.appname }} + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + # prometheus.io/port: "8501" + labels: + release: {{ $.Release.Name }} + app: {{ .Values.appname }} + project: {{ $.Values.project.slug }} + networking/allow-internet-egress: "true" + networking/allow-egress-to-studio-web: "true" + type: app + pod: {{ .Values.appname }} + spec: + {{ if index .Values.flavor.limits "nvidia.com/gpu" }} + affinity: + {{ .Values.affinity | toYaml | nindent 8 | trim }} + {{ end }} + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: vscode + image: {{ .Values.appconfig.image }} #TODO add own image here when we have it - 2023-09-28 + imagePullPolicy: IfNotPresent + command: + - /bin/bash + - -c + - code-server --auth=none --bind-addr 0.0.0.0:8080 + ports: + - containerPort: {{ .Values.service.targetport }} + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + resources: + {{- toYaml .Values.flavor | nindent 10 }} + volumeMounts: + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + mountPath: /home/coder/{{ $key }} + {{- end }} + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + volumes: + {{- range $key, $value := .Values.apps.volumeK8s }} + - name: {{ $key }} + persistentVolumeClaim: + claimName: {{ $value.release }} + {{- end }} diff --git a/apps/vscode/templates/ingress.yaml b/apps/vscode/templates/ingress.yaml new file mode 100644 index 0000000..a1d01bf --- /dev/null +++ b/apps/vscode/templates/ingress.yaml @@ -0,0 +1,54 @@ +{{ if .Values.ingress.v1beta1 }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + 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 +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + serviceName: {{ .Values.service.name }} + servicePort: {{ .Values.service.port }} + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Values.global.domain }} +{{ else }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-ingress + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: {{ .Release.Name }}-ingress + annotations: + 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 +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.global.domain }} + http: + paths: + - path: / + backend: + service: + name: {{ .Values.service.name }} + port: + number: {{ .Values.service.port }} + pathType: ImplementationSpecific + tls: + - secretName: {{ .Values.ingress.secretName }} + hosts: + - {{ .Values.global.domain }} +{{- end }} diff --git a/apps/vscode/templates/service.yaml b/apps/vscode/templates/service.yaml new file mode 100644 index 0000000..12e58b7 --- /dev/null +++ b/apps/vscode/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Release.Namespace }} + labels: + run: {{ .Release.Name }}-vscode +spec: + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetport }} + selector: + release: {{ $.Release.Name }} diff --git a/apps/vscode/values.yaml b/apps/vscode/values.yaml new file mode 100644 index 0000000..ba8e539 --- /dev/null +++ b/apps/vscode/values.yaml @@ -0,0 +1,65 @@ +appname: vscode +project: + name: project + slug: project-slug + +global: + protocol: TCP + + domain: studio.127.0.0.1.nip.io + auth_domain: studio.127.0.0.1.nip.io + +apps: + volumek8s: + +appconfig: + image: codercom/code-server:latest + +affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: acceleration + operator: In + values: + - gpu + +service: + name: vscode-svc + port: 80 + targetport: 8080 + +imagePullSecrets: + - name: regcred + +ingress: + v1beta1: false + secretName: prod-ingress + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + fsGroup: 1000 + +securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + allowPrivilegeEscalation: false + privileged: false + capabilities: + drop: + - all + +flavor: + limits: + cpu: 1 + ephemeral-storage: 800Mi + memory: 1Gi + nvidia.com/gpu: + requests: + cpu: 500m + ephemeral-storage: 500Mi + memory: 500Mi + nvidia.com/gpu: diff --git a/prereq-stack.yaml b/prereq-stack.yaml deleted file mode 100644 index 4b01f6f..0000000 --- a/prereq-stack.yaml +++ /dev/null @@ -1,28 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: stack-fn ---- -apiVersion: v1 -kind: Namespace -metadata: - name: argo ---- -apiVersion: v1 -kind: Namespace -metadata: - name: argo-events ---- -kind: RoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: admin - namespace: default -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: admin -subjects: -- kind: ServiceAccount - name: default - namespace: default diff --git a/scaleout/alliance/.helmignore b/scaleout/alliance/.helmignore deleted file mode 100644 index 50af031..0000000 --- a/scaleout/alliance/.helmignore +++ /dev/null @@ -1,22 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/scaleout/alliance/Chart.yaml b/scaleout/alliance/Chart.yaml deleted file mode 100644 index fd5ee98..0000000 --- a/scaleout/alliance/Chart.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: v1 -name: alliance -description: A Helm chart for Alliance deployment - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -version: 0.1.1 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. -appVersion: latest diff --git a/scaleout/alliance/templates/blocknode-deployment.yaml b/scaleout/alliance/templates/blocknode-deployment.yaml deleted file mode 100644 index e72a182..0000000 --- a/scaleout/alliance/templates/blocknode-deployment.yaml +++ /dev/null @@ -1,43 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-blocknode - name: {{ .Release.Name }}-blocknode -spec: - replicas: 1 - strategy: {} - selector: - matchLabels: - name: {{ .Release.Name }}-blocknode - template: - metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-blocknode - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - - containers: - - args: - - ganache-cli - - --account=0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef,1000000000000000000000000000000000000000 - image: trufflesuite/ganache-cli:latest - imagePullPolicy: "" - name: blocknode - ports: - - containerPort: 8545 - resources: {} - restartPolicy: Always - -status: {} diff --git a/scaleout/alliance/templates/blocknode-service.yaml b/scaleout/alliance/templates/blocknode-service.yaml deleted file mode 100644 index aa2d2ca..0000000 --- a/scaleout/alliance/templates/blocknode-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-blocknode - name: {{ .Release.Name }}-blocknode -spec: - ports: - - name: "8545" - port: 8545 - targetPort: 8545 - selector: - name: {{ .Release.Name }}-blocknode -status: - loadBalancer: {} diff --git a/scaleout/alliance/templates/checkpointer-deployment.yaml b/scaleout/alliance/templates/checkpointer-deployment.yaml deleted file mode 100644 index 43deab2..0000000 --- a/scaleout/alliance/templates/checkpointer-deployment.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-checkpointer - name: {{ .Release.Name }}-checkpointer -spec: - replicas: 1 - strategy: {} - selector: - matchLabels: - name: {{ .Release.Name }}-checkpointer - template: - metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-checkpointer - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - initContainers: - - name: wait-for-delay - image: busybox:1.28 - command: ['sh', '-c', "sleep 20"] - containers: - - args: - - python - - monitor.py - env: - - name: GET_HOSTS_FROM - value: dns - - name: MONITOR_HOST - value: "{{ .Release.Name }}-controller" - - name: MONITOR_PORT - value: "12080" - - name: USER - value: "{{ .Values.alliance.user }}" - - name: PROJECT - value: "{{ .Values.alliance.project }}" - - name: ALLIANCE_UID - value: "{{ .Release.Name }}" - - name: API_URL - value: {{ .Values.alliance.apiUrl }} - image: "{{ .Values.checkpointer.image.repository }}:{{ .Values.checkpointer.image.tag }}" - imagePullPolicy: Always - name: {{ .Release.Name }}-checkpointer - #ports: - #- containerPort: 12080 - # name: grpc - resources: {} - restartPolicy: Always - -status: {} diff --git a/scaleout/alliance/templates/checkpointer-service.yaml b/scaleout/alliance/templates/checkpointer-service.yaml deleted file mode 100644 index baf7683..0000000 --- a/scaleout/alliance/templates/checkpointer-service.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-checkpointer - name: {{ .Release.Name }}-checkpointer -spec: - type: {{ .Values.service.type }} - ports: - - name: http - port: 80 - targetPort: 80 - nodePort: {{ .Values.service.minio}} - selector: - name: {{ .Release.Name }}-checkpointer -status: - loadBalancer: {} diff --git a/scaleout/alliance/templates/controller-deployment.yaml b/scaleout/alliance/templates/controller-deployment.yaml deleted file mode 100644 index 8fd92d4..0000000 --- a/scaleout/alliance/templates/controller-deployment.yaml +++ /dev/null @@ -1,47 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-controller - name: {{ .Release.Name }}-controller -spec: - replicas: 1 - strategy: {} - selector: - matchLabels: - name: {{ .Release.Name }}-controller - template: - metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-controller - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - containers: - - args: - - fedn - - run - - controller - env: - - name: GET_HOSTS_FROM - value: dns - image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag }}" - imagePullPolicy: Always - name: {{ .Release.Name }}-controller - ports: - - containerPort: 12080 - name: grpc - resources: {} - restartPolicy: Always - -status: {} diff --git a/scaleout/alliance/templates/controller-ingress.yaml b/scaleout/alliance/templates/controller-ingress.yaml deleted file mode 100644 index 84c3b70..0000000 --- a/scaleout/alliance/templates/controller-ingress.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: networking.k8s.io/v1beta1 -kind: Ingress -metadata: - annotations: - kubernetes.io/ingress.class: "nginx" - nginx.ingress.kubernetes.io/ssl-redirect: "true" - nginx.ingress.kubernetes.io/backend-protocol: "GRPC" - name: {{ .Release.Name }}-controller-ingress - namespace: default -spec: - rules: - - host: {{ .Release.Name }}.controller.{{ .Values.global.domain }} - http: - paths: - - backend: - serviceName: {{ .Release.Name }}-controller - servicePort: grpc - tls: - # This secret must exist beforehand - # The cert must also contain the subj-name fortune-teller.stack.build - # https://github.com/kubernetes/ingress-nginx/blob/master/docs/examples/PREREQUISITES.md#tls-certificates - - secretName: tls-secret - hosts: - - {{ .Release.Name }}.controller.{{ .Values.global.domain }} \ No newline at end of file diff --git a/scaleout/alliance/templates/controller-service.yaml b/scaleout/alliance/templates/controller-service.yaml deleted file mode 100644 index cc80b78..0000000 --- a/scaleout/alliance/templates/controller-service.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-controller - name: {{ .Release.Name }}-controller -spec: - type: {{ .Values.service.type }} - ports: - - name: grpc - port: 12080 - targetPort: 12080 - nodePort: {{ .Values.service.controller}} - selector: - name: {{ .Release.Name }}-controller -status: - loadBalancer: {} diff --git a/scaleout/alliance/templates/monitor-deployment.yaml b/scaleout/alliance/templates/monitor-deployment.yaml deleted file mode 100644 index a9454bd..0000000 --- a/scaleout/alliance/templates/monitor-deployment.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-monitor - name: {{ .Release.Name }}-monitor -spec: - replicas: 1 - strategy: {} - selector: - matchLabels: - name: {{ .Release.Name }}-monitor - template: - metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-monitor - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - initContainers: - - name: wait-for-delay - image: busybox:1.28 - command: ['sh', '-c', "sleep 20"] - containers: - - args: - - python - - monitor.py - env: - - name: GET_HOSTS_FROM - value: dns - - name: MONITOR_HOST - value: "{{ .Release.Name }}-controller" - - name: MONITOR_PORT - value: "12080" - - name: USER - value: "{{ .Values.alliance.user }}" - - name: PROJECT - value: "{{ .Values.alliance.project }}" - - name: ALLIANCE_UID - value: "{{ .Release.Name }}" - - name: API_URL - value: {{ .Values.alliance.apiUrl }} - image: "{{ .Values.monitor.image.repository }}:{{ .Values.monitor.image.tag }}" - imagePullPolicy: Always - name: {{ .Release.Name }}-monitor - #ports: - #- containerPort: 12080 - # name: grpc - resources: {} - restartPolicy: Always - -status: {} diff --git a/scaleout/alliance/templates/orchestrator-configmap.yaml b/scaleout/alliance/templates/orchestrator-configmap.yaml deleted file mode 100644 index 4c61291..0000000 --- a/scaleout/alliance/templates/orchestrator-configmap.yaml +++ /dev/null @@ -1,41 +0,0 @@ - -kind: ConfigMap -apiVersion: v1 -metadata: - name: {{ .Release.Name }}-orchestrator-configmap -data: - # Configuration values can be set as key-value properties - project.yaml: |- - auth_url: http://{{ .Release.Name }}.{{ .Values.global.domain }}/api/api-token-auth - username: orchestrator - access_key: {{ .Values.minio.access_key | quote}} - password: {{ .Values.minio.secret_key | quote}} - so_domain_name: {{ .Values.global.domain | quote}} - - Project: - project_name: {{ .Values.alliance.project | quote}} - project_id: - - Alliance: - alliance_name: testalliance - controller_host: {{ .Release.Name }}-controller - controller_port: 12080 - #{{ .Values.service.controller | quote }} - - Repository: - minio_host: {{ .Values.alliance.project }}-minio.{{ .Values.global.domain }} - minio_port: 443 - minio_bucket: alliance - minio_access_key: {{ .Values.minio.access_key | quote}} - minio_secret_key: {{ .Values.minio.secret_key | quote}} - minio_secure_mode: True - - Member: - name: orchestrator - entry_points: - predict: - command: python3 predict.py - train: - command: python3 train.py - validate: - command: python3 validate.py diff --git a/scaleout/alliance/templates/orchestrator-deployment.yaml b/scaleout/alliance/templates/orchestrator-deployment.yaml deleted file mode 100644 index eb3ed7b..0000000 --- a/scaleout/alliance/templates/orchestrator-deployment.yaml +++ /dev/null @@ -1,75 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-orchestrator - name: {{ .Release.Name }}-orchestrator -spec: - replicas: 1 - strategy: - type: Recreate - selector: - matchLabels: - name: {{ .Release.Name }}-orchestrator - template: - metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-orchestrator - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - #securityContext: - # runAsUser: 65533 # to allow read of ssh key - #runAsUser: 1000 - #runAsGroup: 3000 - #fsGroup: 2000 - #initContainers: - # - name: wait-for-delay - # image: busybox:1.28 - # command: ['sh', '-c', "sleep {{ .Values.sleep }}"] - containers: - - name: {{ .Release.Name }}-orchestrator - image: "{{ .Values.orchestrator.image.repository }}:{{ .Values.orchestrator.image.tag }}" - imagePullPolicy: Always - #workingDir: /app - command: ['sh','run.sh'] - #args: - #- fedn - #- run - #- fedavg - #- -s - #- {{ .Values.model }} - #- -r - #- {{ .Values.rounds | quote }} - env: - - name: GET_HOSTS_FROM - value: dns - volumeMounts: - - name: project - mountPath: /app/project.yaml - subPath: project.yaml - - #securityContext: - # runAsUser: 0 - #allowPrivilegeEscalation: false - restartPolicy: Always - volumes: - - name: project - configMap: - name: {{ .Release.Name }}-orchestrator-configmap - items: - - key: project.yaml - path: project.yaml - - -status: {} diff --git a/scaleout/alliance/templates/orchestrator-service.yaml b/scaleout/alliance/templates/orchestrator-service.yaml deleted file mode 100644 index af4fa73..0000000 --- a/scaleout/alliance/templates/orchestrator-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert - kompose.version: 1.20.0 () - creationTimestamp: null - labels: - name: {{ .Release.Name }}-orchestrator - name: {{ .Release.Name }}-orchestrator -spec: - ports: - - name: http - port: 80 - targetPort: 80 - selector: - name: {{ .Release.Name }}-orchestrator -status: - loadBalancer: {} diff --git a/scaleout/alliance/values.yaml b/scaleout/alliance/values.yaml deleted file mode 100644 index c5718cf..0000000 --- a/scaleout/alliance/values.yaml +++ /dev/null @@ -1,63 +0,0 @@ -# Default values for alliance-chart. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -model: init-model-id - -global: - domain: alliance.scaleout.se - -alliance: - user: morgan - project: test - apiUrl: "http://studio:8080" - -minio: - access_key: minio - secret_key: minio123 - -controller: - image: - repository: scaleoutsystems/fedn-controller - tag: master - pullPolicy: Always - -monitor: - image: - repository: scaleoutsystems/fedn-monitor - tag: master - pullPolicy: Always - -orchestrator: - image: - repository: scaleoutsystems/fedn-orchestrator - tag: master - pullPolicy: Always - -checkpointer: - image: - repository: scaleoutsystems/fedn-checkpointer - tag: master - pullPolicy: Always - -#imagePullSecrets: -# - name: regcred - -nameOverride: "" -fullnameOverride: "" - - -service: - type: NodePort - controller: 30398 - minio: 30397 - -resources: {} - -nodeSelector: {} - -tolerations: [] - -affinity: {} diff --git a/scaleout/stackn/Chart.yaml b/scaleout/stackn/Chart.yaml deleted file mode 100644 index 061d2ce..0000000 --- a/scaleout/stackn/Chart.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -appVersion: "0.7.0" -description: A Helm chart for deploying studio -name: studio -version: 0.3.0 -maintainers: - - email: fredrik@scaleoutsystems.com - name: Fredrik Wrede diff --git a/scaleout/stackn/README.md b/scaleout/stackn/README.md deleted file mode 100644 index 7aadfde..0000000 --- a/scaleout/stackn/README.md +++ /dev/null @@ -1,139 +0,0 @@ -STACKn -====== -[](https://github.com/scaleoutsystems/charts/actions/workflows/release.yaml) -[](https://github.com/scaleoutsystems/charts/actions/workflows/code-checks.yaml) - -## Description - -A Helm chart for deploying STACKn by Scaleout - -Current chart version is 0.3.0 - -## Chart Requirements - -| Repository | Name | Version | Optional | -|------------|------|---------|----------| -| https://charts.bitnami.com/bitnami | postgresql | 12.2.7 | No -| https://charts.bitnami.com/bitnami | redis | 17.7.4 | No -| https://charts.bitnami.com/bitnami | rabbitmq | 11.9.1 | No -| https://charts.bitnami.com/bitnami | common | 2.0.4 | No -| https://stakater.github.io/stakater-charts | reloader | v1.0.15 | Yes - -## Notes -When using PVC's together with postgres, rabbitmq and and redis, credentials will to not sync if secrets are updated (for example if password values are left blank). If this happens, the solution -is to redeploy and delete previous created PVCs. To avoid the same problem again, either set password values or use existing secrets. The subcharts for postgres, rabbitmq and redis all come with a value -to set existing secret. Existing secrets is the recommended approch if are going to version control your values (GitOps) to avoid raw passwords in your version history. - -You can read more about the issue here: https://github.com/bitnami/charts/issues/2061 -Obs that stakater/reloader does not solve the issue. -## Configuration - -By default STACKn has been configured with a dns wildcard domain for localhost. To change this replace all occurences of studio.127.0.0.1.nip.io in values.yaml. - -By default no StorageClassName is set and needs to provided in the values.yaml or by using `--set` argument. - -### Quick deployment - -```bash -# Deploy STACKn from this repository -helm install --set global.postgresql.storageClass= studio . -``` - -All resources will by default be created in the Namescape "default". -STACKn studio 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. - -## Deploy an SSL certificate - -For production you need a domain name with a wildcard SSL certificate. If your domain is your-domain.com, you will need a certificate for *.your-domain.com and *.studio.your-domain.com. Assuming that your certificate is fullchain.pem and your private key privkey.pem, you can create a secret `prod-ingress` containing the certificate with the command: -``` -kubectl create secret tls prod-ingress --cert fullchain.pem --key privkey.pem -``` - -This secret should be in the same namespace as studio deployment. - -## Enabling network policies -If networkPolicy.enable = true, you have to make sure the correct kubernetes endpoint IP is provided in networkPolicy.kubernetes.cidr, and the correct port networkPolicy.kubernetes.port. This is to enable access of some services to the kubernetes API server through a created Service Account. To get your cluster's kubernetes endpoint run: -``` -kubectl get endpoints kubernetes -``` -To allow for within-cluster DNS, the kube-system namespace need the label: -``` -kubectl label namespace kube-system name=kube-system -``` - -Further, for ingress resources you need to set networkPolicy.ingress_controller_namespace. If value can vary depending on your cluster configuration, but for NGINX ingress controller it's usually "ingress-nginx". - -## Example deployment -``` -global: - studio: - superuserPassword: adminstudio # Django superuser password, username is admin - postgresql: - auth: - username: studio - password: studiopostgrespass - postgresPassword: postgres - database: studio - storageClass: local-path - -namespace: default -networkPolicy: - enable: true - kubernetes: - cidr: 127.0.0.1/32 # To get kubernetes api server endpoints run: $ kubectl get endpoints kubernetes - port: 6443 - internal_cidr: # in-cluster IpBlock cidr, used in allow-internet-[egress|ingress] policy, e.g: - - 10.0.0.0/8 - - 192.168.0.0/16 - - 172.0.0.0/20 - -studio: - debug: false - 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) - 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) - media: - storage: - accessModes: ReadWriteOnce - -accessmode: ReadWriteOnce - -# Postgres deploy with a single-pod database: -postgresql: - primary: - persistence: - size: "2Gi" - accessModes: - - ReadWriteOnce - storageClass: local-path - -rabbit: - password: rabbitmqpass - -redis: - master: - persistence: - enabled: false - replica: - persistence: - enabled: false - -celeryFlower: - enabled: false - -reloader: - enabled: true -``` - - -## Maintainers - -| Name | Email | Url | -| ---- | ------ | --- | -| Fredrik Wrede | fredrik@scaleoutsystems.com | | diff --git a/scaleout/stackn/README.md.gotmpl b/scaleout/stackn/README.md.gotmpl deleted file mode 100644 index 2487a56..0000000 --- a/scaleout/stackn/README.md.gotmpl +++ /dev/null @@ -1,49 +0,0 @@ -STACKn -====== - -## Description - -{{ template "chart.description" . }} - -Current chart version is {{ template "chart.version" . }} - -## Chart Requirements - -{{ template "chart.requirementsTable" . }} - -## Configuration - -By default STACKn has been configured with a dns wildcard domain for localhost. To change this replace all occurences of studio.127.0.0.1.nip.io in values.yaml. - -STACKn requires access to manipulate and create recourses in the k8s cluster. Thus, it needs the cluster config as a secret in ./templates/chart-controller-secret.yaml. - -By default no StorageClassName is set and needs to provided in the values.yaml or by using `--set` argument. - -### Quick deployment - -```bash -# Generate k8s cluster config file - NOTE: we assume a k8s cluster is already installed and configured -cluster_config=$(cat ~/.kube/config | base64 | tr -d '\n') - -# Deploy STACKn from this repository -helm install --set kubeconfig=$cluster_config --set global.postgresql.storageClass= stackn . -``` - -All resources will by default be created in the Namescape "default". -STACKn studio will be avaliable at http://studio.127.0.0.1.nip.io -## Deploy locally without SSL certificates -For local testing/development set `oidc.verify = false`, this will enable insecure options in STACKn without certificates. -## Deploy an SSL certificate - -For production you need a domain name with a wildcard SSL certificate. If your domain is your-domain.com, you will need a certificate for *.your-domain.com and *.studio.your-domain.com. Assuming that your certificate is fullchain.pem and your private key privkey.pem, you can create a secret `prod-ingress` containing the certificate with the command: -``` -kubectl create secret tls prod-ingress --cert fullchain.pem --key privkey.pem -``` - -{{ template "chart.valuesHeader" . }} - -{{ template "chart.valuesTable" . }} - -{{ template "chart.maintainersHeader" . }} - -{{ template "chart.maintainersTable" . }} diff --git a/scaleout/stackn/charts/common-2.0.4.tgz b/scaleout/stackn/charts/common-2.0.4.tgz deleted file mode 100644 index 54b9a53..0000000 Binary files a/scaleout/stackn/charts/common-2.0.4.tgz and /dev/null differ diff --git a/scaleout/stackn/charts/postgresql-12.2.7.tgz b/scaleout/stackn/charts/postgresql-12.2.7.tgz deleted file mode 100644 index a62d858..0000000 Binary files a/scaleout/stackn/charts/postgresql-12.2.7.tgz and /dev/null differ diff --git a/scaleout/stackn/charts/rabbitmq-11.9.1.tgz b/scaleout/stackn/charts/rabbitmq-11.9.1.tgz deleted file mode 100644 index 2c6b1ab..0000000 Binary files a/scaleout/stackn/charts/rabbitmq-11.9.1.tgz and /dev/null differ diff --git a/scaleout/stackn/charts/redis-17.7.4.tgz b/scaleout/stackn/charts/redis-17.7.4.tgz deleted file mode 100644 index 7679d02..0000000 Binary files a/scaleout/stackn/charts/redis-17.7.4.tgz and /dev/null differ diff --git a/scaleout/stackn/charts/reloader-v1.0.15.tgz b/scaleout/stackn/charts/reloader-v1.0.15.tgz deleted file mode 100644 index 9505045..0000000 Binary files a/scaleout/stackn/charts/reloader-v1.0.15.tgz and /dev/null differ diff --git a/scaleout/stackn/requirements.yaml b/scaleout/stackn/requirements.yaml deleted file mode 100644 index 2892f8b..0000000 --- a/scaleout/stackn/requirements.yaml +++ /dev/null @@ -1,57 +0,0 @@ -# version x.x.x corresponds to "latest" -dependencies: - # - name: openfaas - # version: 5.6.5 - # repository: "https://openfaas.github.io/faas-netes/" - # condition: openfaas.enabled - - # - name: argo-events - # version: 0.14.0 - # repository: "https://argoproj.github.io/argo-helm" - # condition: argo-events.enabled - - # - name: argo - # version: 0.7.3 - # repository: "https://argoproj.github.io/argo-helm" - # condition: argo.enabled - - # - name: prometheus - # version: 13.8.0 - # repository: https://prometheus-community.github.io/helm-charts - # condition: prometheus.enabled - - # - name: grafana - # version: 6.8.4 - # repository: https://grafana.github.io/helm-charts - # condition: grafana.enabled - - - name: reloader - version: v1.0.15 - repository: https://stakater.github.io/stakater-charts - condition: reloader.enabled - - # - name: postgresql-ha - # version: 9.2.0 - # repository: https://charts.bitnami.com/bitnami - # condition: postgresql-ha.enabled - - - name: postgresql - version: 12.2.7 - repository: https://charts.bitnami.com/bitnami - condition: postgresql.enabled - - - name: redis - version: 17.7.4 - repository: https://charts.bitnami.com/bitnami - condition: redis.enabled - - - name: rabbitmq - version: 11.9.1 - repository: https://charts.bitnami.com/bitnami - condition: rabbitmq.enabled - - - name: common - repository: https://charts.bitnami.com/bitnami - tags: - - bitnami-common - version: 2.0.4 diff --git a/scaleout/stackn/values-utility-script.sh b/scaleout/stackn/values-utility-script.sh deleted file mode 100755 index f0cc445..0000000 --- a/scaleout/stackn/values-utility-script.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# v0.1.0 -# Script can be improved by for example taking into account that this works only first time -# Later times strings such as and will already be overwritten - -set -e - -echo "Running the utility script for setting up variables within the values.yaml file..." -# Extract currently assigned IP address (which is connected to Internet!) - -echo "Extracting IP address..." -my_ip=$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," ");print a[1]}') -echo "Your current IP address is: $my_ip" - -# Extract used network interface - Just for sysadmin purposes -#my_interface=$(ip route get 8.8.8.8 | awk -F"dev " 'NR==1{split($2,a," ");print a[1]}') - -# Replace field with extracted IP adress in values.yaml file -echo "Replacing $my_ip inside the values.yaml file..." -echo "Appending nip.io wildcardars..." -sed -i "s//$my_ip.nip.io/g" ./values.yaml -echo "Your current STACKn domain will be: $my_ip.nip.io" - - -# Generate k8s cluster config file - NOTE: we assume that microk8s is already installed and configured -cluster_config=$(microk8s.config | base64 | tr -d '\n') - -# Replace field in the chart-controller-secret.yaml file with the above create variable -sed -i "s//$cluster_config/g" ./templates/chart-controller-secret.yaml - -echo "Done" - diff --git a/scaleout/stackn/.helmignore b/serve/.helmignore similarity index 100% rename from scaleout/stackn/.helmignore rename to serve/.helmignore diff --git a/serve/Chart.yaml b/serve/Chart.yaml new file mode 100644 index 0000000..77ac066 --- /dev/null +++ b/serve/Chart.yaml @@ -0,0 +1,35 @@ +apiVersion: v1 +appVersion: "1.1.0-beta" +description: A Helm chart for deploying Serve +name: studio +version: 1.0.0 +maintainers: + - email: serve@scilifelab.se + name: Team Whale + +dependencies: + - name: reloader + version: v1.0.15 + repository: https://stakater.github.io/stakater-charts + condition: reloader.enabled + + - name: postgresql + version: 12.2.7 + repository: https://charts.bitnami.com/bitnami + condition: postgresql.enabled + + - name: redis + version: 17.7.4 + repository: https://charts.bitnami.com/bitnami + condition: redis.enabled + + - name: rabbitmq + version: 11.9.1 + repository: https://charts.bitnami.com/bitnami + condition: rabbitmq.enabled + + - name: common + repository: https://charts.bitnami.com/bitnami + tags: + - bitnami-common + version: 2.0.4 diff --git a/scaleout/stackn/templates/_helper.tpl b/serve/templates/_helper.tpl similarity index 100% rename from scaleout/stackn/templates/_helper.tpl rename to serve/templates/_helper.tpl diff --git a/scaleout/stackn/templates/basic-secrets.yaml b/serve/templates/basic-secrets.yaml similarity index 97% rename from scaleout/stackn/templates/basic-secrets.yaml rename to serve/templates/basic-secrets.yaml index dfa18b3..f359061 100644 --- a/scaleout/stackn/templates/basic-secrets.yaml +++ b/serve/templates/basic-secrets.yaml @@ -5,7 +5,7 @@ metadata: name: {{ template "common.names.fullname" . }} labels: {{- include "common.labels.standard" . | nindent 4 }} - namespace: {{ .Release.Namespace }} + namespace: {{ .Values.namespace }} type: Opaque data: studio-superuser-password: {{ include "common.secrets.passwords.manage" (dict "secret" (include "common.names.fullname" .) "key" "studio-superuser-password" "providedValues" (list "global.studio.superuserPassword" "studio.superuserPassword") "context" $) }} diff --git a/scaleout/stackn/templates/celery-beat-deployment.yaml b/serve/templates/celery-beat-deployment.yaml similarity index 100% rename from scaleout/stackn/templates/celery-beat-deployment.yaml rename to serve/templates/celery-beat-deployment.yaml diff --git a/scaleout/stackn/templates/celery-flower-deployment.yaml b/serve/templates/celery-flower-deployment.yaml similarity index 100% rename from scaleout/stackn/templates/celery-flower-deployment.yaml rename to serve/templates/celery-flower-deployment.yaml diff --git a/scaleout/stackn/templates/celery-flower-service.yaml b/serve/templates/celery-flower-service.yaml similarity index 100% rename from scaleout/stackn/templates/celery-flower-service.yaml rename to serve/templates/celery-flower-service.yaml diff --git a/scaleout/stackn/templates/celery-worker-deployment.yaml b/serve/templates/celery-worker-deployment.yaml similarity index 99% rename from scaleout/stackn/templates/celery-worker-deployment.yaml rename to serve/templates/celery-worker-deployment.yaml index cfd429b..1a8e735 100644 --- a/scaleout/stackn/templates/celery-worker-deployment.yaml +++ b/serve/templates/celery-worker-deployment.yaml @@ -24,6 +24,7 @@ spec: io.kompose.service: {{ .Release.Name }}-celery-worker name: {{ .Release.Name }}-celery-worker app: stackn-studio + networking/allow-internet-egress: "true" allow-api-access: "true" spec: serviceAccountName: {{ include "common.names.fullname" .}} diff --git a/scaleout/stackn/templates/chart-controller-secret.yaml b/serve/templates/chart-controller-secret.yaml similarity index 100% rename from scaleout/stackn/templates/chart-controller-secret.yaml rename to serve/templates/chart-controller-secret.yaml diff --git a/scaleout/stackn/templates/event-listener-deployment.yaml b/serve/templates/event-listener-deployment.yaml similarity index 100% rename from scaleout/stackn/templates/event-listener-deployment.yaml rename to serve/templates/event-listener-deployment.yaml diff --git a/scaleout/stackn/templates/ingress-platform.yaml b/serve/templates/ingress-platform.yaml similarity index 100% rename from scaleout/stackn/templates/ingress-platform.yaml rename to serve/templates/ingress-platform.yaml diff --git a/scaleout/stackn/templates/media-vol.yaml b/serve/templates/media-vol.yaml similarity index 100% rename from scaleout/stackn/templates/media-vol.yaml rename to serve/templates/media-vol.yaml diff --git a/scaleout/stackn/templates/network-policies.yaml b/serve/templates/network-policies.yaml similarity index 100% rename from scaleout/stackn/templates/network-policies.yaml rename to serve/templates/network-policies.yaml diff --git a/scaleout/stackn/templates/nginx-conf.yaml b/serve/templates/nginx-conf.yaml similarity index 100% rename from scaleout/stackn/templates/nginx-conf.yaml rename to serve/templates/nginx-conf.yaml diff --git a/scaleout/stackn/templates/nginx-deployment.yaml b/serve/templates/nginx-deployment.yaml similarity index 100% rename from scaleout/stackn/templates/nginx-deployment.yaml rename to serve/templates/nginx-deployment.yaml diff --git a/scaleout/stackn/templates/nginx-service.yaml b/serve/templates/nginx-service.yaml similarity index 100% rename from scaleout/stackn/templates/nginx-service.yaml rename to serve/templates/nginx-service.yaml diff --git a/scaleout/stackn/templates/role.yaml b/serve/templates/role.yaml similarity index 100% rename from scaleout/stackn/templates/role.yaml rename to serve/templates/role.yaml diff --git a/scaleout/stackn/templates/rolebinding.yaml b/serve/templates/rolebinding.yaml similarity index 100% rename from scaleout/stackn/templates/rolebinding.yaml rename to serve/templates/rolebinding.yaml diff --git a/scaleout/stackn/templates/service-account.yaml b/serve/templates/service-account.yaml similarity index 86% rename from scaleout/stackn/templates/service-account.yaml rename to serve/templates/service-account.yaml index 38a66b6..4da1145 100644 --- a/scaleout/stackn/templates/service-account.yaml +++ b/serve/templates/service-account.yaml @@ -6,7 +6,7 @@ automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountT {{- end }} metadata: name: {{ include "common.names.fullname" .}} - namespace: {{ .Values.namespace | default .Release.Namespace }} + namespace: {{ .Values.namespace | default .Values.namespace }} {{- end }} --- apiVersion: v1 diff --git a/scaleout/stackn/templates/studio-deployment.yaml b/serve/templates/studio-deployment.yaml similarity index 98% rename from scaleout/stackn/templates/studio-deployment.yaml rename to serve/templates/studio-deployment.yaml index 75c2cb5..73dcaa9 100644 --- a/scaleout/stackn/templates/studio-deployment.yaml +++ b/serve/templates/studio-deployment.yaml @@ -81,6 +81,8 @@ spec: secretKeyRef: name: {{ include "stackn.secretName" . }} key: studio-superuser-password + - name: EVENT_USER_EMAIL + value: {{ include "stackn.studio.eventuser.email" . }} - name: EVENT_USER_PASSWORD valueFrom: secretKeyRef: diff --git a/scaleout/stackn/templates/studio-service.yaml b/serve/templates/studio-service.yaml similarity index 100% rename from scaleout/stackn/templates/studio-service.yaml rename to serve/templates/studio-service.yaml diff --git a/scaleout/stackn/templates/studio-settings-configmap.yaml b/serve/templates/studio-settings-configmap.yaml similarity index 78% rename from scaleout/stackn/templates/studio-settings-configmap.yaml rename to serve/templates/studio-settings-configmap.yaml index f4a0f00..1bd9877 100644 --- a/scaleout/stackn/templates/studio-settings-configmap.yaml +++ b/serve/templates/studio-settings-configmap.yaml @@ -15,11 +15,16 @@ data: For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ - + import logging import os import sys from pathlib import Path + import colorlog + import structlog + + from studio.utils import add_loggers + AUTHENTICATION_BACKENDS = [ "axes.backends.AxesStandaloneBackend", @@ -77,6 +82,10 @@ data: "sekizai.context_processors.sekizai", ] + STRUCTLOG_MIDDLEWARE = [ + "django_structlog.middlewares.RequestMiddleware" + ] + DJANGO_STRUCTLOG_CELERY_ENABLED = not DEBUG # Application definition @@ -93,6 +102,7 @@ data: 'django_celery_beat', 'django_extensions', # for executing runscript among others 'django_filters', + 'django_structlog', 'tagulous', 'guardian', "portal", @@ -104,6 +114,8 @@ data: "customtags", "news", "axes", # django-axes for brute force login protection + "django_password_validators", # django-password-validators for password validation + "collections_module", ] + DJANGO_WIKI_APPS {{ if .Values.studio.custom_apps.enabled }} @@ -116,17 +128,22 @@ data: {{ end }} - MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'corsheaders.middleware.CorsMiddleware', - "axes.middleware.AxesMiddleware", - ] + DJANGO_WIKI_MIDDLEWARE + MIDDLEWARE = ( + [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", + "corsheaders.middleware.CorsMiddleware", + "axes.middleware.AxesMiddleware", + "studio.middleware.ExceptionLoggingMiddleware" + ] + + DJANGO_WIKI_MIDDLEWARE + + (STRUCTLOG_MIDDLEWARE if not DEBUG else []) + ) REST_FRAMEWORK = { @@ -200,6 +217,7 @@ data: 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'common.context_processors.maintenance_mode', ] + DJANGO_WIKI_CONTEXT_PROCESSOR, 'libraries': { @@ -227,13 +245,16 @@ data: } # Session settings for managing automatic login expiration. - # The age of session cookies, in seconds. Set to 1 day = 86400 seconds: + # The age of session cookies, in seconds. Default set to 1 day = 86400 seconds: SESSION_COOKIE_AGE = {{ .Values.studio.session_cookie_age | default 86400 }} # Whether to save the session data on every request. For sliding expiration: SESSION_SAVE_EVERY_REQUEST = True # Whether to expire the session when the user closes their browser: SESSION_EXPIRE_AT_BROWSER_CLOSE = False + # The expiration duration in seconds for authentication tokens. Default set to 1 day: + AUTH_TOKEN_EXPIRATION = {{ .Values.studio.auth_token_expiration | default 86400 }} + # Settings for the Django Axes brute force login protection # Number of allowed login failures before action is taken AXES_FAILURE_LIMIT = {{ .Values.studio.axes_failure_limit | default 10 }} @@ -259,6 +280,9 @@ data: }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + 'OPTIONS': { + 'min_length': 10, + }, }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', @@ -266,6 +290,19 @@ data: { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, + { + 'NAME': ( + 'django_password_validators.password_character_requirements.password_validation.PasswordCharacterValidator' + ), + 'OPTIONS': { + 'min_length_digit': 1, + 'min_length_alpha': 2, + 'min_length_special': 1, + 'min_length_lower': 1, + 'min_length_upper': 1, + 'special_characters': "~!@#$%^&*()_+{}\":;'[]", + }, + }, ] # Internationalization @@ -385,6 +422,7 @@ data: 'projects': 'studio.migrations.projects', "common": "common.migrations", "news": "news.migrations", + "collections_module": "collections_module.migrations", } {{ if .Values.studio.custom_migrations.enabled }} @@ -435,3 +473,67 @@ data: # Specifically, apps.tests.test_user_has_no_access was failing. # Also anonymous access to pages was not working. ANONYMOUS_USER_NAME = None + + LOGGING = { + "version": 1, + "disable_existing_loggers": False, + "formatters": { + "json_formatter": { + "()": structlog.stdlib.ProcessorFormatter, + "processor": structlog.processors.JSONRenderer(), + }, + "colored": { + "()": colorlog.ColoredFormatter, + "datefmt": "%Y-%m-%d %H:%M:%S", + "log_colors": { + "DEBUG": "blue", + "INFO": "green", + "WARNING": "yellow", + "ERROR": "red", + "CRITICAL": "bold_red", + }, + "format": "%(log_color)s%(asctime)s - %(levelname)s - %(name)s: %(message)s%(reset)s", + }, + }, + "handlers": { + "console": { + "class": "logging.StreamHandler", + "formatter": "colored", + }, + "json": { + "class": "logging.StreamHandler", + "formatter": "json_formatter", + }, + }, + "loggers": { + "": { + "handlers": ["console" if DEBUG else "json"], + "level": "DEBUG" if DEBUG else "INFO", + }, + "django.server": { + "handlers": ["console" if DEBUG else "json"], + "level": "WARNING", + "propagate": False, + }, + }, + } + + LOGGING = add_loggers(LOGGING, INSTALLED_APPS) + + if not DEBUG: + structlog.configure( + processors=[ + structlog.contextvars.merge_contextvars, + structlog.stdlib.filter_by_level, + structlog.processors.TimeStamper(fmt="iso"), + structlog.stdlib.add_logger_name, + structlog.stdlib.add_log_level, + structlog.stdlib.PositionalArgumentsFormatter(), + structlog.processors.StackInfoRenderer(), + structlog.processors.format_exc_info, + structlog.processors.UnicodeDecoder(), + structlog.stdlib.ProcessorFormatter.wrap_for_formatter, + ], + logger_factory=structlog.stdlib.LoggerFactory(), + cache_logger_on_first_use=True, + ) diff --git a/scaleout/stackn/values.yaml b/serve/values.yaml similarity index 98% rename from scaleout/stackn/values.yaml rename to serve/values.yaml index 7a46776..3c5cec7 100644 --- a/scaleout/stackn/values.yaml +++ b/serve/values.yaml @@ -25,7 +25,7 @@ global: storageClass: -namespace: default + existingSecret: "" serviceAccount: create: true @@ -78,7 +78,7 @@ studio: replicas: 1 strategy: type: Recreate - image: ghcr.io/scilifelabdatacentre/stackn/serve-ingress:develop-20240215 + image: ghcr.io/scilifelabdatacentre/stackn/serve-ingress:develop-20240326 pullPolicy: IfNotPresent resources: limits: @@ -88,7 +88,7 @@ studio: cpu: "100m" memory: "256Mi" image: - repository: ghcr.io/scilifelabdatacentre/stackn/serve-studio:develop-20240215 + repository: ghcr.io/scilifelabdatacentre/stackn/serve-studio:develop-20240326 pullPolicy: IfNotPresent resources: limits: @@ -109,10 +109,10 @@ studio: mount_path: /app/media/ superUser: admin superuserPassword: "" - superuserEmail: admin@test.com + superuserEmail: admin@serve.scilifelab.se eventUser: "" eventuserPassword: "" - eventuserEmail: "" + eventuserEmail: event_user@serve.scilifelab.se version: studio securityContext: enabled: true @@ -265,7 +265,7 @@ grafana: reloader: enabled: true - namespace: default + reloader: watchGlobally: false