diff --git a/.helm/adhoc/certificate.yaml b/.helm/adhoc/certificate.yaml index 329e79e..80ba87e 100644 --- a/.helm/adhoc/certificate.yaml +++ b/.helm/adhoc/certificate.yaml @@ -1,12 +1,13 @@ +--- apiVersion: cert-manager.io/v1 kind: Certificate metadata: - name: siibra-spatial-backend + name: siibra-spatial-backend-canonical spec: - commonName: siibra-spatial-backend.apps.tc.humanbrainproject.eu + commonName: siibra-spatial-backend.apps.ebrains.eu isCA: false dnsNames: - - siibra-spatial-backend.apps.tc.humanbrainproject.eu + - siibra-spatial-backend.apps.ebrains.eu issuerRef: kind: ClusterIssuer name: letsencrypt-production-issuer-1 @@ -15,6 +16,27 @@ spec: encoding: PKCS1 size: 2048 renewBefore: 120h - secretName: siibra-spatial-backend-secret + secretName: siibra-spatial-backend-canonical-secret usages: - server auth +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: siibra-spatial-backend-dev +spec: + commonName: siibra-spatial-backend-dev.apps.tc.humanbrainproject.eu + isCA: false + dnsNames: + - siibra-spatial-backend-dev.apps.tc.humanbrainproject.eu + issuerRef: + kind: ClusterIssuer + name: letsencrypt-production-issuer-1 + privateKey: + algorithm: RSA + encoding: PKCS1 + size: 2048 + renewBefore: 120h + secretName: siibra-spatial-backend-dev-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..6ac6d0a --- /dev/null +++ b/.helm/adhoc/configmap.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +data: + config.py: | + CORS_ORIGINS = '*' + PROXY_FIX = { + 'x_for': 1, + 'x_host': 1, + 'x_port': 1, + 'x_proto': 1, + } + DEFAULT_TRANSFORM_GRAPH = '/static-data/DISCO_20181004_sigV30_DARTEL_20181004_reg_x4/graph.yaml' + + config_v2.py: | + CORS_ORIGINS = '*' + PROXY_FIX = { + 'x_for': 1, + 'x_host': 1, + 'x_port': 1, + 'x_proto': 1, + } + ENV: 'development' + DEFAULT_TRANSFORM_GRAPH = '/static-data/DISCO_20181004_sigV30_DARTEL_20250708_reg_x4/graph.yaml' +kind: ConfigMap +metadata: + name: siibra-spatial-backend-adhoc diff --git a/.helm/adhoc/deployment-busybox.yaml b/.helm/adhoc/deployment-busybox.yaml index d365b6a..dde71d0 100644 --- a/.helm/adhoc/deployment-busybox.yaml +++ b/.helm/adhoc/deployment-busybox.yaml @@ -27,9 +27,11 @@ spec: limits: cpu: 100m memory: 128Mi + ephemeral-storage: 32Mi requests: cpu: 100m memory: 128Mi + ephemeral-storage: 32Mi volumeMounts: - mountPath: /static-data name: data-volume diff --git a/.helm/adhoc/ingress.yaml b/.helm/adhoc/ingress.yaml new file mode 100644 index 0000000..259cd0a --- /dev/null +++ b/.helm/adhoc/ingress.yaml @@ -0,0 +1,39 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: hbp-spatial-backend-ingress + labels: + name: hbp-spatial-backend-ingress + annotations: + nginx.ingress.kubernetes.io/app-root: "/redoc" +spec: + ingressClassName: nginx + rules: + - host: siibra-spatial-backend.apps.ebrains.eu + http: + paths: + - path: / + pathType: ImplementationSpecific + backend: + service: + name: prod-hbp-spatial-backend + port: + number: 8080 + - host: siibra-spatial-backend-dev.apps.tc.humanbrainproject.eu + http: + paths: + - path: / + pathType: ImplementationSpecific + backend: + service: + name: dev-hbp-spatial-backend + port: + number: 8080 + tls: + - secretName: siibra-spatial-backend-canonical-secret + hosts: + - siibra-spatial-backend.apps.ebrains.eu + + - secretName: siibra-spatial-backend-dev-secret + hosts: + - siibra-spatial-backend-dev.apps.tc.humanbrainproject.eu diff --git a/.helm/deployments/dev/create.sh b/.helm/deployments/dev/create.sh new file mode 100644 index 0000000..d392d62 --- /dev/null +++ b/.helm/deployments/dev/create.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +helm install \ + --set envObj.HBP_SPATIAL_BACKEND_SETTINGS="/instance/config_v2.py" \ + --set replicaCount=1 \ + dev \ + ./.helm/hbp_spatial_backend \ No newline at end of file diff --git a/.helm/hbp_spatial_backend/Chart.yaml b/.helm/hbp_spatial_backend/Chart.yaml index 44e3d28..1f170b6 100644 --- a/.helm/hbp_spatial_backend/Chart.yaml +++ b/.helm/hbp_spatial_backend/Chart.yaml @@ -15,7 +15,7 @@ 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 +version: 0.1.2 # 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 diff --git a/.helm/hbp_spatial_backend/templates/configmap.yaml b/.helm/hbp_spatial_backend/templates/configmap.yaml deleted file mode 100644 index 77f3f87..0000000 --- a/.helm/hbp_spatial_backend/templates/configmap.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: v1 -data: - config.py: | - CORS_ORIGINS = '*' - PROXY_FIX = { - 'x_for': 1, - 'x_host': 1, - 'x_port': 1, - 'x_proto': 1, - } - DEFAULT_TRANSFORM_GRAPH = '/static-data/DISCO_20181004_sigV30_DARTEL_20181004_reg_x4/graph.yaml' -kind: ConfigMap -metadata: - name: siibra-spatial-backend - labels: - {{- include "hbp_spatial_backend.labels" . | nindent 4 }} diff --git a/.helm/hbp_spatial_backend/templates/deployment.yaml b/.helm/hbp_spatial_backend/templates/deployment.yaml index 2c6607f..e92b463 100644 --- a/.helm/hbp_spatial_backend/templates/deployment.yaml +++ b/.helm/hbp_spatial_backend/templates/deployment.yaml @@ -48,6 +48,11 @@ spec: httpGet: path: /health port: http + env: + {{- range $key, $val := .Values.envObj }} + - name: {{ $key }} + value: {{ $val }} + {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} {{- with .Values.volumeMounts }} diff --git a/.helm/hbp_spatial_backend/values.yaml b/.helm/hbp_spatial_backend/values.yaml index 2f00bfb..c0a3aeb 100644 --- a/.helm/hbp_spatial_backend/values.yaml +++ b/.helm/hbp_spatial_backend/values.yaml @@ -44,20 +44,20 @@ service: port: 8080 ingress: - enabled: true + enabled: false className: "nginx" annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" hosts: - - host: siibra-spatial-backend.apps.tc.humanbrainproject.eu + - host: siibra-spatial-backend.apps.ebrains.eu paths: - path: / pathType: ImplementationSpecific tls: - - secretName: siibra-spatial-backend-secret + - secretName: siibra-spatial-backend-canonical-secret hosts: - - siibra-spatial-backend.apps.tc.humanbrainproject.eu + - siibra-spatial-backend.apps.ebrains.eu resources: # We usually recommend not to specify default resources and to leave this as a conscious @@ -67,9 +67,11 @@ resources: limits: cpu: 300m memory: 1024Mi + ephemeral-storage: 64Mi requests: cpu: 150m memory: 256Mi + ephemeral-storage: 64Mi autoscaling: enabled: false @@ -86,7 +88,7 @@ volumes: - name: config-vol configMap: defaultMode: 420 - name: siibra-spatial-backend + name: siibra-spatial-backend-adhoc # Additional volumeMounts on the output Deployment definition. volumeMounts: @@ -100,3 +102,6 @@ nodeSelector: {} tolerations: [] affinity: {} + +envObj: + HBP_SPATIAL_BACKEND_SETTINGS: /instance/config.py diff --git a/hbp_spatial_backend/__init__.py b/hbp_spatial_backend/__init__.py index a366ebb..b16f984 100644 --- a/hbp_spatial_backend/__init__.py +++ b/hbp_spatial_backend/__init__.py @@ -100,8 +100,7 @@ def create_app(test_config=None): exclude_useragent_re = re.compile(r'kube-probe') access_logger.addFilter( lambda record: not ( - record.args['h'].startswith('10.') - and record.args['m'] == 'GET' + record.args['m'] == 'GET' and record.args['U'] == '/health' and exclude_useragent_re.search(record.args['a']) )