diff --git a/deployment/Chart.yaml b/deployment/Chart.yaml index 7550d2a..d42cf34 100644 --- a/deployment/Chart.yaml +++ b/deployment/Chart.yaml @@ -2,20 +2,6 @@ apiVersion: v2 name: trs-filer description: A Helm chart for Kubernetes icon: https://avatars.githubusercontent.com/u/60704687?s=48&v=4 -# 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: 1.16.0 +version: 2.0.0 +appVersion: 2.0.0 diff --git a/deployment/templates/NOTES.txt b/deployment/templates/NOTES.txt new file mode 100644 index 0000000..65e0a89 --- /dev/null +++ b/deployment/templates/NOTES.txt @@ -0,0 +1,11 @@ +Elixir Cloud TRS-Filer is being deployed! + +Once deployed: + + 1. Access the API via https://{{ .Values.host_name }}/ga4gh/trs/v2/ + + To test the connection, you can run: + + curl -X GET "https://{{ .Values.host_name }}/ga4gh/trs/v2/service-info" -H "Accept: application/json" + + 2. Access the Swagger UI via https://{{ .Values.host_name }}/ga4gh/trs/v2/ui diff --git a/deployment/templates/mongo-deploy.yaml b/deployment/templates/mongo-deploy.yaml index 36b6c7e..8735a86 100644 --- a/deployment/templates/mongo-deploy.yaml +++ b/deployment/templates/mongo-deploy.yaml @@ -27,12 +27,15 @@ spec: ports: - containerPort: 27017 protocol: TCP - resources: {} + resources: {{- toYaml .Values.mongodb.resources | nindent 10 }} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /data/db/ name: mongodb-{{ .Values.trs_filer.appName }} + - name: init-script + mountPath: /docker-entrypoint-initdb.d/init-script.js + subPath: init-script.js dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler @@ -42,4 +45,6 @@ spec: - name: mongodb-{{ .Values.trs_filer.appName }} persistentVolumeClaim: claimName: mongodb-{{ .Values.trs_filer.appName }} -status: + - name: init-script + configMap: + name: mongo-init-script diff --git a/deployment/templates/mongo-init-script.yaml b/deployment/templates/mongo-init-script.yaml new file mode 100644 index 0000000..56f7472 --- /dev/null +++ b/deployment/templates/mongo-init-script.yaml @@ -0,0 +1,45 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: mongo-init-script +data: + init-script.js: | + db = db.getSiblingDB('trsStore'); + // https://github.com/elixir-cloud-aai/trs-filer/blob/9116b702bce2ef5b2e04130a6fe5db2a89d465f3/trs_filer/gunicorn.py#L26 + // If not set in values.yaml, it will use trs-filer-db + dbTRS = db.getSiblingDB('{{ tpl (default "trs-filer-db" .Values.mongodb.dbName) . }}'); + + // Create the 'tools', 'service_info' and 'toolclasses' collections + // Database configuration from https://github.com/elixir-cloud-aai/trs-filer/blob/9116b702bce2ef5b2e04130a6fe5db2a89d465f3/trs_filer/config.yaml#L9 + db.createCollection('tools'); + db.tools.createIndex( + { id: 1 }, + { unique: true } + ); + db.createCollection('service_info'); + db.service_info.createIndex( + { id: 1 }, + { unique: true } + ); + db.createCollection('toolclasses'); + db.toolclasses.createIndex( + { id: 1 }, + { unique: true } + ); + + dbTRS.createCollection('tools'); + dbTRS.tools.createIndex( + { id: 1 }, + { unique: true } + ); + dbTRS.createCollection('service_info'); + dbTRS.service_info.createIndex( + { id: 1 }, + { unique: true } + ); + dbTRS.createCollection('toolclasses'); + dbTRS.toolclasses.createIndex( + { id: 1 }, + { unique: true } + ); + diff --git a/deployment/templates/mongo-pvc.yaml b/deployment/templates/mongo-pvc.yaml index d702e9b..645be09 100644 --- a/deployment/templates/mongo-pvc.yaml +++ b/deployment/templates/mongo-pvc.yaml @@ -4,7 +4,7 @@ metadata: name: mongodb-{{ .Values.trs_filer.appName }} spec: accessModes: - - ReadWriteOnce + - ReadWriteOnce resources: requests: storage: {{ .Values.mongodb.volumeSize }} diff --git a/deployment/templates/trs-filer-deploy.yaml b/deployment/templates/trs-filer-deploy.yaml index 2acdd74..17754ab 100644 --- a/deployment/templates/trs-filer-deploy.yaml +++ b/deployment/templates/trs-filer-deploy.yaml @@ -24,10 +24,15 @@ spec: - image: {{ .Values.trs_filer.image }} imagePullPolicy: Always name: {{ .Values.trs_filer.appName }} + # https://github.com/elixir-cloud-aai/trs-filer/blob/9116b702bce2ef5b2e04130a6fe5db2a89d465f3/trs_filer/gunicorn.py#L26 + # If not set in values.yaml, it will use trs-filer-db + env: + - name: MONGO_DBNAME + value: {{ .Values.mongodb.dbName | default "trs-filer-db" }} ports: - containerPort: 8080 protocol: TCP - resources: {} + resources: {{- toYaml .Values.trs_filer.resources | nindent 10 }} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: @@ -46,6 +51,5 @@ spec: - key: config.yaml path: config.yaml name: app-config-{{ .Values.trs_filer.appName }} - name: config-yaml -status: + diff --git a/deployment/templates/trs-filer-ingress.yaml b/deployment/templates/trs-filer-ingress.yaml new file mode 100644 index 0000000..025f965 --- /dev/null +++ b/deployment/templates/trs-filer-ingress.yaml @@ -0,0 +1,29 @@ +{{ if .Values.trs_filer.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + {{- if .Values.trs_filer.ingress.https.enabled }} + cert-manager.io/cluster-issuer: {{ .Values.trs_filer.ingress.https.issuer }} + kubernetes.io/tls-acme: "true" + {{- end }} + name: {{ .Values.trs_filer.appName }}-ingress +spec: + rules: + - host: {{ .Values.host_name }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Values.trs_filer.appName }} + port: + number: 8080 +{{- if .Values.trs_filer.ingress.https.enabled }} + tls: + - hosts: + - {{ .Values.host_name }} + secretName: {{ .Values.trs_filer.appName }}-ingress-secret +{{- end }} +{{ end }} diff --git a/deployment/templates/trs-filer-route.yaml b/deployment/templates/trs-filer-route.yaml index fa5395f..0c138e7 100644 --- a/deployment/templates/trs-filer-route.yaml +++ b/deployment/templates/trs-filer-route.yaml @@ -1,8 +1,8 @@ -{{ if .Capabilities.APIVersions.Has "route.openshift.io/v1" }} +{{ if ( and (.Capabilities.APIVersions.Has "route.openshift.io/v1") (not .Values.trs_filer.ingress.enabled)) }} apiVersion: route.openshift.io/v1 kind: Route metadata: - name: {{ .Values.trs_filer.appName }} + name: {{ .Values.trs_filer.appName }}-route spec: host: {{ .Values.host_name }} port: @@ -17,35 +17,4 @@ spec: wildcardPolicy: None status: ingress: [] -{{ else if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }} -{{ if .Values.kubernetes.ingress.enabled }} -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - annotations: - kubernetes.io/ingress.class: nginx - {{ if .Values.kubernetes.ingress.enabled }} - cert-manager.io/cluster-issuer: {{ .Values.kubernetes.https.issuer }} - kubernetes.io/tls-acme: "true" - {{ end }} - name: {{ .Values.trs_filer.appName }}-ingress -spec: - rules: - - host: {{ .Values.host_name }} - http: - paths: - - backend: - service: - name: {{ .Values.trs_filer.appName }} - port: - number: 8080 - path: / - pathType: Prefix -{{ if .Values.kubernetes.https.enabled }} - tls: - - hosts: - - {{ .Values.host_name }} - secretName: {{ .Values.trs_filer.appName }}-ingress-secret -{{ end }} -{{ end }} {{ end }} diff --git a/deployment/values.yaml b/deployment/values.yaml index e2bea78..55d072c 100644 --- a/deployment/values.yaml +++ b/deployment/values.yaml @@ -2,25 +2,38 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -host_name: trs-filer-test.2.rahtiapp.fi +host_name: "" trs_filer: + # if ingress.enabled: false, it will deploy an OpenShift Route (https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/network_apis/route-route-openshift-io-v1) + ingress: + enabled: true + https: + enabled: false + issuer: letsencrypt-prod image: elixircloud/trs-filer:latest appName: trs-filer + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi apiServer: kubernetes.default.svc:443 # address of k8s API server -# If you are running kubernetes select whether you would like -# to access the service via Ingress. Also, if you have the cert manager -# installed, you can provision a certificate for https -kubernetes: - ingress: - enabled: true - https: - enabled: true - issuer: letsencrypt-prod - mongodb: - image: mongo:3.6 + image: docker.io/library/mongo:noble + # https://github.com/elixir-cloud-aai/trs-filer/blob/9116b702bce2ef5b2e04130a6fe5db2a89d465f3/trs_filer/gunicorn.py#L26 + # If not set, it will use trs-filer-db + dbName: "" volumeSize: 1Gi + resources: + limits: + cpu: 200m + memory: 512Mi + requests: + cpu: 200m + memory: 512Mi