From 7f36ab0dfbac60e4820a015968f290f5e77ed563 Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Thu, 7 Mar 2024 16:56:30 +0100 Subject: [PATCH] maint: add helm scripts --- .github/workflows/deploy-helm.yml | 39 +++++++ .github/workflows/dockerimg.yml | 59 +++++++--- .gitignore | 2 + .helm/adhoc/cert-rc-ebrains.yaml | 21 ++++ .helm/adhoc/cert-rc-tc.yaml | 21 ++++ .helm/adhoc/certificate.yaml | 21 ++++ .helm/adhoc/example-secrets-oidc.yaml | 12 +++ .helm/voluba-prod/.helmignore | 23 ++++ .helm/voluba-prod/Chart.yaml | 24 +++++ .helm/voluba-prod/templates/NOTES.txt | 22 ++++ .helm/voluba-prod/templates/_helpers.tpl | 62 +++++++++++ .helm/voluba-prod/templates/deployment.yaml | 82 ++++++++++++++ .helm/voluba-prod/templates/hpa.yaml | 32 ++++++ .helm/voluba-prod/templates/ingress.yaml | 61 +++++++++++ .helm/voluba-prod/templates/service.yaml | 15 +++ .../voluba-prod/templates/serviceaccount.yaml | 13 +++ .../templates/tests/test-connection.yaml | 15 +++ .helm/voluba-prod/values.yaml | 101 ++++++++++++++++++ backend/voluba_backend/viewer_plugin.py | 2 +- 19 files changed, 614 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/deploy-helm.yml create mode 100644 .helm/adhoc/cert-rc-ebrains.yaml create mode 100644 .helm/adhoc/cert-rc-tc.yaml create mode 100644 .helm/adhoc/certificate.yaml create mode 100644 .helm/adhoc/example-secrets-oidc.yaml create mode 100644 .helm/voluba-prod/.helmignore create mode 100644 .helm/voluba-prod/Chart.yaml create mode 100644 .helm/voluba-prod/templates/NOTES.txt create mode 100644 .helm/voluba-prod/templates/_helpers.tpl create mode 100644 .helm/voluba-prod/templates/deployment.yaml create mode 100644 .helm/voluba-prod/templates/hpa.yaml create mode 100644 .helm/voluba-prod/templates/ingress.yaml create mode 100644 .helm/voluba-prod/templates/service.yaml create mode 100644 .helm/voluba-prod/templates/serviceaccount.yaml create mode 100644 .helm/voluba-prod/templates/tests/test-connection.yaml create mode 100644 .helm/voluba-prod/values.yaml diff --git a/.github/workflows/deploy-helm.yml b/.github/workflows/deploy-helm.yml new file mode 100644 index 00000000..17cdd83c --- /dev/null +++ b/.github/workflows/deploy-helm.yml @@ -0,0 +1,39 @@ +name: Trigger deploy with helm +on: + workflow_call: + + inputs: + DEPLOYMENT_NAME: + required: true + type: string + IMAGE_TAG: + required: true + type: string + + secrets: + KUBECONFIG: + required: true + +env: + path_to_helm: .helm/voluba-prod + INGRESS_HOST: '[{ "host": "voluba-staging.apps.tc.humanbrainproject.eu", "paths": [{ "path": "/", "pathType": "Prefix" }] }]' + TLS: '[{ "secretName": "voluba-rc-tc-secret", "hosts": ["voluba-staging.apps.tc.humanbrainproject.eu"] }]' + ENV_HOSTNAME: 'https://voluba-staging.apps.tc.humanbrainproject.eu' + +jobs: + trigger-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: 'Deploy' + run: | + kubecfg_path=${{ runner.temp }}/.kube_config + echo "${{ secrets.KUBECONFIG }}" > $kubecfg_path + + helm --kubeconfig=$kubecfg_path \ + upgrade \ + --reuse-values \ + --set image.tag=${{ inputs.IMAGE_TAG }} \ + ${{ inputs.DEPLOYMENT_NAME }} ${{ env.path_to_helm }} + + rm $kubecfg_path diff --git a/.github/workflows/dockerimg.yml b/.github/workflows/dockerimg.yml index 3074804c..de653f58 100644 --- a/.github/workflows/dockerimg.yml +++ b/.github/workflows/dockerimg.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - mvp_nehubaUpdated - staging # do not rebuild if... @@ -14,14 +13,16 @@ on: env: OKD_URL: https://okd.hbp.eu:443 - jobs: build-docker-img: runs-on: ubuntu-latest - + env: + DOCKERIMG: voluba + outputs: + VERSION: ${{ steps.setting-vars.outputs.VERSION }} steps: - - uses: actions/checkout@v2 - - name: 'Setup envvar' + - uses: actions/checkout@v4 + - name: 'Setup tags' run: | if [[ $GITHUB_REF == 'refs/heads/master' ]]; then echo "DOCKERIMG=voluba:latest" >> "$GITHUB_ENV" @@ -29,9 +30,6 @@ jobs: if [[ $GITHUB_REF == 'refs/heads/staging' ]]; then echo "DOCKERIMG=voluba:staging" >> "$GITHUB_ENV" fi - if [[ $GITHUB_REF == 'refs/heads/mvp_nehubaUpdated' ]]; then - echo "DOCKERIMG=voluba:mvp_nehubaUpdated" >> "$GITHUB_ENV" - fi - name: 'Setup tags' run: | if [[ -z "$DOCKERIMG" ]] @@ -48,14 +46,16 @@ jobs: echo "MATOMO_ID=${{ secrets.MATOMO_ID_PROD }}" >> $GITHUB_ENV - name: 'Set version variable & expmt feature flag' + id: 'setting-vars' run: | GIT_HASH=$(git rev-parse --short HEAD) echo "Setting GIT_HASH: $GIT_HASH" - echo "GIT_HASH=$GIT_HASH" >> $GITHUB_ENV + echo "GIT_HASH=$GIT_HASH" >> $GITHUB_OUTPUT - # VERSION=$(jq -r '.version' package.json) - # echo "Setting VERSION: $VERSION" - # echo "VERSION=$VERSION" >> $GITHUB_ENV + VERSION=$(jq -r '.version' app/package.json) + echo "Setting VERSION: $VERSION" + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "VERSION=$VERSION" >> $GITHUB_ENV # VUE_APP_ENABLE_EXPERIMENTAL_FEATURES="{}" @@ -79,8 +79,43 @@ jobs: -u '${{ secrets.EBRAINS_DOCKER_REG_USER }}' \ -p '${{ secrets.EBRAINS_DOCKER_REG_TOKEN }}' \ docker-registry.ebrains.eu + echo "Pushing $DOCKER_IMGSTREAM" docker push $DOCKER_IMGSTREAM + + - name: 'Tag and push version' + if: ${{ github.ref == 'refs/heads/master' }} + run: | + VERSIONED_DOCKER_IMGSTREAM=${{ secrets.EBRAINS_DOCKER_REG_VOLUBA_NSP }}/${{ env.DOCKERIMG }}:$VERSION + echo "Tagging and pushing $VERSIONED_DOCKER_IMGSTREAM" + docker tag $DOCKER_IMGSTREAM $VERSIONED_DOCKER_IMGSTREAM + + docker login \ + -u '${{ secrets.EBRAINS_DOCKER_REG_USER }}' \ + -p '${{ secrets.EBRAINS_DOCKER_REG_TOKEN }}' \ + docker-registry.ebrains.eu + + docker push $VERSIONED_DOCKER_IMGSTREAM + + deploy-prod-on-rancher: + needs: [ build-docker-img ] + if: ${{ github.ref == 'refs/heads/master' && success() }} + uses: ./.github/workflows/deploy-helm.yml + with: + DEPLOYMENT_NAME: voluba-prod + IMAGE_TAG: ${{ needs.build-docker-img.outputs.VERSION }} + secrets: + KUBECONFIG: ${{ secrets.KUBECONFIG }} + + deploy-rc-on-rancher: + needs: [ build-docker-img ] + if: ${{ github.ref == 'refs/heads/staging' && success() }} + uses: ./.github/workflows/deploy-helm.yml + with: + DEPLOYMENT_NAME: voluba-rc + IMAGE_TAG: staging + secrets: + KUBECONFIG: ${{ secrets.KUBECONFIG }} deploy-on-okd: needs: [ build-docker-img ] diff --git a/.gitignore b/.gitignore index 43f4ac4c..5f8d8b8f 100644 --- a/.gitignore +++ b/.gitignore @@ -227,3 +227,5 @@ pyvenv.cfg pip-selfcheck.json # End of https://www.gitignore.io/api/python,pycharm + +secret* \ No newline at end of file diff --git a/.helm/adhoc/cert-rc-ebrains.yaml b/.helm/adhoc/cert-rc-ebrains.yaml new file mode 100644 index 00000000..05bab61c --- /dev/null +++ b/.helm/adhoc/cert-rc-ebrains.yaml @@ -0,0 +1,21 @@ +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: voluba-rc-ebrains-certificate +spec: + secretName: voluba-rc-ebrains-secret + renewBefore: 120h + commonName: voluba-staging.apps.ebrains.eu + isCA: false + privateKey: + algorithm: RSA + encoding: PKCS1 + size: 2048 + usages: + - server auth + dnsNames: + # (CHANGE ME! same as `commonName`) + - voluba-staging.apps.ebrains.eu + issuerRef: + name: letsencrypt-production-issuer-1 + kind: ClusterIssuer diff --git a/.helm/adhoc/cert-rc-tc.yaml b/.helm/adhoc/cert-rc-tc.yaml new file mode 100644 index 00000000..cff3df3a --- /dev/null +++ b/.helm/adhoc/cert-rc-tc.yaml @@ -0,0 +1,21 @@ +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: voluba-rc-tc-certificate +spec: + secretName: voluba-rc-tc-secret + renewBefore: 120h + commonName: voluba-staging.apps.tc.humanbrainproject.eu + isCA: false + privateKey: + algorithm: RSA + encoding: PKCS1 + size: 2048 + usages: + - server auth + dnsNames: + # (CHANGE ME! same as `commonName`) + - voluba-staging.apps.tc.humanbrainproject.eu + issuerRef: + name: letsencrypt-production-issuer-1 + kind: ClusterIssuer \ No newline at end of file diff --git a/.helm/adhoc/certificate.yaml b/.helm/adhoc/certificate.yaml new file mode 100644 index 00000000..d594c08c --- /dev/null +++ b/.helm/adhoc/certificate.yaml @@ -0,0 +1,21 @@ +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: voluba-certificate +spec: + secretName: voluba-prod-secret + renewBefore: 120h + commonName: voluba.apps.tc.humanbrainproject.eu + isCA: false + privateKey: + algorithm: RSA + encoding: PKCS1 + size: 2048 + usages: + - server auth + dnsNames: + # (CHANGE ME! same as `commonName`) + - voluba.apps.tc.humanbrainproject.eu + issuerRef: + name: letsencrypt-production-issuer-1 + kind: ClusterIssuer \ No newline at end of file diff --git a/.helm/adhoc/example-secrets-oidc.yaml b/.helm/adhoc/example-secrets-oidc.yaml new file mode 100644 index 00000000..03200b4f --- /dev/null +++ b/.helm/adhoc/example-secrets-oidc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: voluba-oidc +type: Opaque +data: + EBRAINS_SA_CLIENT_ID: Zm9v + EBRAINS_SA_CLIENT_SECRET: Zm9v + HBP_V2_CLIENTID: Zm9v + HBP_V2_CLIENTSECRET: Zm9v + ORCID_CLIENTID: Zm9v + ORCID_CLIENTSECRET: Zm9v diff --git a/.helm/voluba-prod/.helmignore b/.helm/voluba-prod/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/.helm/voluba-prod/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/.helm/voluba-prod/Chart.yaml b/.helm/voluba-prod/Chart.yaml new file mode 100644 index 00000000..e57d8db4 --- /dev/null +++ b/.helm/voluba-prod/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: voluba-prod +description: A Helm chart for Kubernetes Voluba + +# 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. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +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. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.1.1" diff --git a/.helm/voluba-prod/templates/NOTES.txt b/.helm/voluba-prod/templates/NOTES.txt new file mode 100644 index 00000000..309cb4fe --- /dev/null +++ b/.helm/voluba-prod/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "voluba-prod.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "voluba-prod.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "voluba-prod.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "voluba-prod.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/.helm/voluba-prod/templates/_helpers.tpl b/.helm/voluba-prod/templates/_helpers.tpl new file mode 100644 index 00000000..21a2e04c --- /dev/null +++ b/.helm/voluba-prod/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "voluba-prod.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 "voluba-prod.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 "voluba-prod.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "voluba-prod.labels" -}} +helm.sh/chart: {{ include "voluba-prod.chart" . }} +{{ include "voluba-prod.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "voluba-prod.selectorLabels" -}} +app.kubernetes.io/name: {{ include "voluba-prod.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "voluba-prod.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "voluba-prod.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/.helm/voluba-prod/templates/deployment.yaml b/.helm/voluba-prod/templates/deployment.yaml new file mode 100644 index 00000000..03a5babe --- /dev/null +++ b/.helm/voluba-prod/templates/deployment.yaml @@ -0,0 +1,82 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "voluba-prod.fullname" . }} + labels: + {{- include "voluba-prod.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "voluba-prod.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "voluba-prod.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "voluba-prod.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - secretRef: + name: voluba-oidc + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + + env: + {{- range $key, $val := .Values.env }} + - name: {{ $key }} + value: {{ $val }} + {{- end }} + + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/.helm/voluba-prod/templates/hpa.yaml b/.helm/voluba-prod/templates/hpa.yaml new file mode 100644 index 00000000..630fc39b --- /dev/null +++ b/.helm/voluba-prod/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "voluba-prod.fullname" . }} + labels: + {{- include "voluba-prod.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "voluba-prod.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/.helm/voluba-prod/templates/ingress.yaml b/.helm/voluba-prod/templates/ingress.yaml new file mode 100644 index 00000000..feb4bcbc --- /dev/null +++ b/.helm/voluba-prod/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "voluba-prod.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "voluba-prod.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/.helm/voluba-prod/templates/service.yaml b/.helm/voluba-prod/templates/service.yaml new file mode 100644 index 00000000..a6543fe0 --- /dev/null +++ b/.helm/voluba-prod/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "voluba-prod.fullname" . }} + labels: + {{- include "voluba-prod.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "voluba-prod.selectorLabels" . | nindent 4 }} diff --git a/.helm/voluba-prod/templates/serviceaccount.yaml b/.helm/voluba-prod/templates/serviceaccount.yaml new file mode 100644 index 00000000..36a742f8 --- /dev/null +++ b/.helm/voluba-prod/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "voluba-prod.serviceAccountName" . }} + labels: + {{- include "voluba-prod.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/.helm/voluba-prod/templates/tests/test-connection.yaml b/.helm/voluba-prod/templates/tests/test-connection.yaml new file mode 100644 index 00000000..a2f90bcf --- /dev/null +++ b/.helm/voluba-prod/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "voluba-prod.fullname" . }}-test-connection" + labels: + {{- include "voluba-prod.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "voluba-prod.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/.helm/voluba-prod/values.yaml b/.helm/voluba-prod/values.yaml new file mode 100644 index 00000000..8d5d7f46 --- /dev/null +++ b/.helm/voluba-prod/values.yaml @@ -0,0 +1,101 @@ +# Default values for voluba-prod. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: docker-registry.ebrains.eu/voluba/voluba + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +env: + HOSTNAME: https://voluba.apps.tc.humanbrainproject.eu + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 8080 + +ingress: + enabled: true + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: voluba.apps.tc.humanbrainproject.eu + paths: + - path: / + pathType: Prefix + tls: + - secretName: voluba-prod-secret + hosts: + - voluba.apps.tc.humanbrainproject.eu + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/backend/voluba_backend/viewer_plugin.py b/backend/voluba_backend/viewer_plugin.py index a6ea787c..74daf929 100644 --- a/backend/voluba_backend/viewer_plugin.py +++ b/backend/voluba_backend/viewer_plugin.py @@ -15,7 +15,7 @@ def verify_transform(transform: str): to_number = [ float(v) for v in transform.split(",") ] - if len(to_number) != 12 or any([math.isnan(v) for v in to_number]): + if len(to_number) != 12 or any(math.isnan(v) for v in to_number): return None return [ to_number[:4],