diff --git a/.helm/adhoc/cert.yaml b/.helm/adhoc/cert.yaml new file mode 100644 index 0000000..dbdfcb8 --- /dev/null +++ b/.helm/adhoc/cert.yaml @@ -0,0 +1,42 @@ +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: siibra-jugex-certificate +spec: + isCA: false + commonName: siibra-jugex.apps.tc.humanbrainproject.eu + dnsNames: + - siibra-jugex.apps.tc.humanbrainproject.eu + issuerRef: + kind: ClusterIssuer + name: letsencrypt-production-issuer-1 + privateKey: + algorithm: RSA + encoding: PKCS1 + size: 2048 + renewBefore: 120h0m0s + secretName: siibra-jugex-prod-secret + usages: + - server auth +--- + +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: neurogenpy-certificate +spec: + isCA: false + commonName: ngpy.apps.hbp.eu + dnsNames: + - ngpy.apps.hbp.eu + issuerRef: + kind: ClusterIssuer + name: letsencrypt-production-issuer-1 + privateKey: + algorithm: RSA + encoding: PKCS1 + size: 2048 + renewBefore: 120h0m0s + secretName: neurogenpy-prod-secret + usages: + - server auth \ No newline at end of file diff --git a/.helm/adhoc/configmap.yaml b/.helm/adhoc/configmap.yaml new file mode 100644 index 0000000..22913c6 --- /dev/null +++ b/.helm/adhoc/configmap.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: jugex-toolbox +data: + SIIBRA_TOOLBOX_LOG_DIR: /siibra-tool-log + SIIBRA_TOOLBOX_DATA_DIR: /siibra-tool-data + SIIBRA_JURGEX_CELERY_BROKER: redis://redis:6379 + SIIBRA_JURGEX_CELERY_RESULT: redis://redis:6379 + SIIBRA_CACHEDIR: /siibra-tool-data/tmp diff --git a/.helm/adhoc/cron.yaml b/.helm/adhoc/cron.yaml new file mode 100644 index 0000000..067cb56 --- /dev/null +++ b/.helm/adhoc/cron.yaml @@ -0,0 +1,30 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: cronjob-trim-old-log-usage +spec: + # run two month + schedule: "41 1 */5 */2 *" + concurrencyPolicy: Replace + jobTemplate: + spec: + template: + spec: + containers: + - name: cronjob-trim-old-log-usage + image: docker-registry.ebrains.eu/monitoring/kubectl:v1.29.2 + imagePullPolicy: Always + command: + - /bin/ash + - -c + # delete all files over 30 days of modification date + - "find /siibra-tool-log -mindepth 1 -maxdepth 1 -mtime +30 -delete" + volumeMounts: + - mountPath: /siibra-tool-log + name: log-volume + + restartPolicy: OnFailure + volumes: + - name: log-volume + persistentVolumeClaim: + claimName: log-volume-claim-2 diff --git a/.helm/adhoc/deployment.yaml b/.helm/adhoc/deployment.yaml new file mode 100644 index 0000000..194d952 --- /dev/null +++ b/.helm/adhoc/deployment.yaml @@ -0,0 +1,60 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: redis +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: redis + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + labels: + app: redis + spec: + containers: + - image: docker-registry.ebrains.eu/monitoring/redis:alpine3.17 + imagePullPolicy: IfNotPresent + livenessProbe: + exec: + command: + - redis-cli + - ping + failureThreshold: 3 + periodSeconds: 30 + successThreshold: 1 + timeoutSeconds: 1 + name: redis + ports: + - containerPort: 6379 + protocol: TCP + readinessProbe: + exec: + command: + - redis-cli + - ping + failureThreshold: 3 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: + limits: + cpu: 200m + memory: 1Gi + requests: + cpu: 100m + memory: 128Mi + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 diff --git a/.helm/adhoc/ingress.yaml b/.helm/adhoc/ingress.yaml new file mode 100644 index 0000000..c86fa3f --- /dev/null +++ b/.helm/adhoc/ingress.yaml @@ -0,0 +1,33 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: jugex-toolbox +spec: + rules: + - host: siibra-jugex.apps.tc.humanbrainproject.eu + http: + paths: + - backend: + service: + name: jugex-toolbox + port: + number: 6001 + path: / + pathType: ImplementationSpecific + - host: ngpy.apps.hbp.eu + http: + paths: + - backend: + service: + name: neurogenpy-toolbox + port: + number: 6001 + path: / + pathType: ImplementationSpecific + tls: + - hosts: + - siibra-jugex.apps.tc.humanbrainproject.eu + secretName: siibra-jugex-prod-secret + - hosts: + - ngpy.apps.hbp.eu + secretName: neurogenpy-prod-secret diff --git a/.helm/adhoc/pvc.yaml b/.helm/adhoc/pvc.yaml new file mode 100644 index 0000000..f01a2c6 --- /dev/null +++ b/.helm/adhoc/pvc.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + type: longhorn-pvc + name: data-volume-claim +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 16Gi + storageClassName: longhorn-1 +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + type: longhorn-pvc + name: log-volume-claim-2 +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 4Gi + storageClassName: longhorn-1 \ No newline at end of file diff --git a/.helm/adhoc/service.yaml b/.helm/adhoc/service.yaml new file mode 100644 index 0000000..effbac2 --- /dev/null +++ b/.helm/adhoc/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: redis + name: redis +spec: + ports: + - port: 6379 + protocol: TCP + targetPort: 6379 + selector: + app: redis + type: ClusterIP \ No newline at end of file diff --git a/.helm/deploy_neurogenpy.sh b/.helm/deploy_neurogenpy.sh new file mode 100755 index 0000000..92dad14 --- /dev/null +++ b/.helm/deploy_neurogenpy.sh @@ -0,0 +1,16 @@ +#! /bin/bash + +SERVER_IMG="docker-registry.ebrains.eu/siibra-toolbox/neurogenpy" +WORKER_IMG="docker-registry.ebrains.eu/siibra-toolbox/neurogenpy" +SERVER_TAG="server" +WORKER_TAG="worker" + +helm install neurogenpy ./toolbox \ + --set image.serverRepository=$SERVER_IMG \ + --set image.workerRepository=$WORKER_IMG \ + --set image.serverTag=$SERVER_TAG \ + --set image.workerTag=$WORKER_TAG \ + --set workerResources.limits.memory=4Gi \ + --set envObj.NEUROGENPY_CELERY_BROKER=redis://redis:6379 \ + --set envObj.NEUROGENPY_CELERY_RESULT=redis://redis:6379 + \ No newline at end of file diff --git a/.helm/toolbox/.helmignore b/.helm/toolbox/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/.helm/toolbox/.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/toolbox/Chart.yaml b/.helm/toolbox/Chart.yaml new file mode 100644 index 0000000..36ab714 --- /dev/null +++ b/.helm/toolbox/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: toolbox +description: A Helm chart for Kubernetes + +# 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.0 + +# 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: "0.0.2" diff --git a/.helm/toolbox/templates/NOTES.txt b/.helm/toolbox/templates/NOTES.txt new file mode 100644 index 0000000..3d4da44 --- /dev/null +++ b/.helm/toolbox/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 "toolbox.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 "toolbox.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "toolbox.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 "toolbox.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/toolbox/templates/_helpers.tpl b/.helm/toolbox/templates/_helpers.tpl new file mode 100644 index 0000000..eb4b86f --- /dev/null +++ b/.helm/toolbox/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "toolbox.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 "toolbox.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 "toolbox.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "toolbox.labels" -}} +helm.sh/chart: {{ include "toolbox.chart" . }} +{{ include "toolbox.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "toolbox.selectorLabels" -}} +app.kubernetes.io/name: {{ include "toolbox.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "toolbox.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "toolbox.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/.helm/toolbox/templates/hpa.yaml b/.helm/toolbox/templates/hpa.yaml new file mode 100644 index 0000000..e1cbb58 --- /dev/null +++ b/.helm/toolbox/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "toolbox.fullname" . }} + labels: + {{- include "toolbox.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "toolbox.fullname" . }}-worker + 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/toolbox/templates/ingress.yaml b/.helm/toolbox/templates/ingress.yaml new file mode 100644 index 0000000..5ccb94f --- /dev/null +++ b/.helm/toolbox/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "toolbox.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 "toolbox.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/toolbox/templates/server-deployment.yaml b/.helm/toolbox/templates/server-deployment.yaml new file mode 100644 index 0000000..e5a87ed --- /dev/null +++ b/.helm/toolbox/templates/server-deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "toolbox.fullname" . }}-server + labels: + {{- include "toolbox.labels" . | nindent 4 }} + role: server +spec: + replicas: 1 + selector: + matchLabels: + {{- include "toolbox.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "toolbox.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + role: server + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "toolbox.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.serverRepository }}:{{ .Values.image.serverTag | default .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + envFrom: + - configMapRef: + name: jugex-toolbox + - secretRef: + name: ebrains-lab-integration + env: + {{- range $key, $val := .Values.envObj }} + - name: {{ $key }} + value: {{ $val }} + {{- end }} + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.serverResources | 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/toolbox/templates/service.yaml b/.helm/toolbox/templates/service.yaml new file mode 100644 index 0000000..188dd25 --- /dev/null +++ b/.helm/toolbox/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "toolbox.fullname" . }} + labels: + {{- include "toolbox.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + role: server + {{- include "toolbox.selectorLabels" . | nindent 4 }} diff --git a/.helm/toolbox/templates/serviceaccount.yaml b/.helm/toolbox/templates/serviceaccount.yaml new file mode 100644 index 0000000..458bcdc --- /dev/null +++ b/.helm/toolbox/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "toolbox.serviceAccountName" . }} + labels: + {{- include "toolbox.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/.helm/toolbox/templates/tests/test-connection.yaml b/.helm/toolbox/templates/tests/test-connection.yaml new file mode 100644 index 0000000..79a5768 --- /dev/null +++ b/.helm/toolbox/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "toolbox.fullname" . }}-test-connection" + labels: + {{- include "toolbox.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "toolbox.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/.helm/toolbox/templates/worker-deployment.yaml b/.helm/toolbox/templates/worker-deployment.yaml new file mode 100644 index 0000000..18b1527 --- /dev/null +++ b/.helm/toolbox/templates/worker-deployment.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "toolbox.fullname" . }}-worker + labels: + {{- include "toolbox.labels" . | nindent 4 }} + role: worker +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "toolbox.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "toolbox.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + role: worker + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "toolbox.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + envFrom: + - configMapRef: + name: jugex-toolbox + env: + {{- range $key, $val := .Values.envObj }} + - name: {{ $key }} + value: {{ $val }} + {{- end }} + + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.workerRepository }}:{{ .Values.image.workerTag | default .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + resources: + {{- toYaml .Values.workerResources | 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/toolbox/values.yaml b/.helm/toolbox/values.yaml new file mode 100644 index 0000000..cee9367 --- /dev/null +++ b/.helm/toolbox/values.yaml @@ -0,0 +1,119 @@ +# Default values for toolbox. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + serverRepository: docker-registry.ebrains.eu/siibra-toolbox/siibra-jugex-server + workerRepository: docker-registry.ebrains.eu/siibra-toolbox/siibra-jugex-worker + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + serverTag: "" + workerTag: "" + tag: "" + +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: 6001 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +serverResources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 100m + memory: 128Mi + +workerResources: + limits: + cpu: 1500m + memory: 1Gi + requests: + cpu: 600m + memory: 512Mi + +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: +- name: log-volume + persistentVolumeClaim: + claimName: log-volume-claim +- name: data-volume + persistentVolumeClaim: + claimName: data-volume-claim + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: +- mountPath: /siibra-tool-log + name: log-volume +- mountPath: /siibra-tool-data + name: data-volume + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +envObj: {} \ No newline at end of file diff --git a/http_wrapper/server.py b/http_wrapper/server.py index 8520be8..4d22656 100644 --- a/http_wrapper/server.py +++ b/http_wrapper/server.py @@ -53,4 +53,19 @@ def shutdown_event(): # TODO doesn't work quite right # shutdown handler isn't called until ctrl+c is hit twice on_exit() - \ No newline at end of file + + +do_not_logs = ( + "GET / HTTP", +) + +import logging +class EndpointLoggingFilter(logging.Filter): + """Custom logger filter. Do not log metrics, ready endpoint.""" + def filter(self, record: logging.LogRecord) -> bool: + message = record.getMessage() + return all( + message.find(do_not_log) == -1 for do_not_log in do_not_logs + ) + +logging.getLogger("uvicorn.access").addFilter(EndpointLoggingFilter())