diff --git a/charts/drinkn/templates/mongo.yaml b/charts/drinkn/templates/mongo.yaml new file mode 100644 index 000000000..fed0b5bd3 --- /dev/null +++ b/charts/drinkn/templates/mongo.yaml @@ -0,0 +1,58 @@ +{{- if .Values.pr.enabled }} +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mongodb +spec: + replicas: 1 + serviceName: mongodb + selector: + matchLabels: + app: mongodb + template: + metadata: + labels: + app: mongodb + spec: + containers: + - name: mongodb + image: mongo:4.4.18 + ports: + - containerPort: 27017 + env: + - name: MONGO_INITDB_ROOT_USERNAME + valueFrom: + secretKeyRef: + name: drinkn-env + key: DB_USERNAME + - name: MONGO_INITDB_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: drinkn-env + key: DB_PASSWORD + volumeMounts: + - name: mongo-storage + mountPath: /data/db + volumeClaimTemplates: + - metadata: + name: mongo-storage + spec: + storageClassName: ceph-filesystem + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 1Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: mongodb +spec: + selector: + app: mongodb + ports: + - protocol: TCP + port: 27017 + targetPort: 27017 +{{- end }} diff --git a/charts/drinkn/templates/secrets.yaml b/charts/drinkn/templates/secrets.yaml index 3b0b02205..38c1cb055 100644 --- a/charts/drinkn/templates/secrets.yaml +++ b/charts/drinkn/templates/secrets.yaml @@ -19,5 +19,19 @@ spec: JWTSECRET: AgALWkvAQhvlK6ISn521rfVHmu8R9k90dNT+0xU/EkUGh6m1egHkg53LdknlCM3fwJ6Yk7Zp8eaZ6m7nHIJzRCbn8wLrGQZzoPOFa9LgvRXxXL6CPNBUzzypU8uFNzUuSYBYY+rCSofczOavdrR+JEqPuYiRse7jdtdv0dAC1rTROtRfdkF36B9Nh9QZGtuc8SR6EeLgCoqfC28UiEQVCatAZKAWuXAfQ0HrHWcHps1JARw12FhL/qZITLYxkDD5R/45us7QHWJzlQ1IJd6O3ZuAeWiRLavnOSBy4EFfKUhvCscZb0tkPku9ssM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fWCvvtBCzlUYCGMkwaHMz1mlPMejAK3cDd8YKgF43fzhef+k86fPp460r55AOK7mqIFtqOWXymbFrRqcG+zqkHFSJRr6tCrYrTNicDve91WL64hIQ7zrmppDrT507+qJPpbxDUYGTrZedo1R05GR5vfx7Eiax2yTB5Yo6vNutaoG3QI/V+ZBA++BIFcGw0Cfiunto/Q0A== {{- else }} -# TODO dev secret +--- +apiVersion: v1 +kind: Secret +metadata: + name: drinkn-env +stringData: + APPSECRET: test + DB_HOST: mongodb.srv.cluster.local + DB_NAME: test + DB_USERNAME: test + DB_PASSWORD: test + DEFAULT_USER: test + DEFAULT_PASS: test + JWTSECRET: test + NO_SRV: "true" {{- end }} diff --git a/pils/server.js b/pils/server.js index ff77f5500..8249acfe5 100644 --- a/pils/server.js +++ b/pils/server.js @@ -1,6 +1,14 @@ if (process.env.NODE_ENV !== 'production') require('dotenv').config() // use the .env file for this require('./setup') -const connectionString = `mongodb+srv://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}/${process.env.DB_NAME}` + +let mongoProtocol +if (process.env.NO_SRV) { + mongoProtocol = 'mongodb' +} else { + mongoProtocol = 'mongodb+srv' +} + +const connectionString = `${mongoProtocol}://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}/${process.env.DB_NAME}` const express = require('express') const history = require('connect-history-api-fallback')