Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions deployment/templates/mongo-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
45 changes: 45 additions & 0 deletions deployment/templates/mongo-init-script.yaml
Original file line number Diff line number Diff line change
@@ -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');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Repeated collection/index creation may cause errors if collections already exist.

Consider adding checks to ensure collections and indexes are only created if they do not already exist, or handle errors to prevent failures on repeated deployments.

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 }
);

2 changes: 1 addition & 1 deletion deployment/templates/mongo-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: mongodb-{{ .Values.trs_filer.appName }}
spec:
accessModes:
- ReadWriteOnce
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.mongodb.volumeSize }}
Expand Down
10 changes: 7 additions & 3 deletions deployment/templates/trs-filer-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -46,6 +51,5 @@ spec:
- key: config.yaml
path: config.yaml
name: app-config-{{ .Values.trs_filer.appName }}

name: config-yaml
status:

30 changes: 30 additions & 0 deletions deployment/templates/trs-filer-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{ if .Values.trs_filer.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
{{- 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 }}
35 changes: 2 additions & 33 deletions deployment/templates/trs-filer-route.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 }}
37 changes: 25 additions & 12 deletions deployment/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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