Skip to content

Commit

Permalink
add mongodb
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren committed Jun 24, 2024
1 parent 8453a81 commit b140b3e
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 9 deletions.
18 changes: 18 additions & 0 deletions charts/tracetest-cloud/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ Expand the name of the chart.
{{- end -}}
{{- end -}}

{{- define "tracetest-cloud.mongodb_dsn" -}}
{{- $global := .Values.global.mongodb.auth -}}
{{- $options := $global.options | default dict -}}
{{- $options_str := "" -}}
{{- range $key, $value := $options -}}
{{- if $options_str }}
{{- $options_str = printf "%s&%s=%s" $options_str $key $value -}}
{{- else }}
{{- $options_str = printf "%s=%s" $key $value -}}
{{- end -}}
{{- end -}}
{{- if $options_str }}
{{- printf "%s://%s:%s@%s/%s?%s" $global.protocol $global.username $global.password $global.host $global.database $options_str -}}
{{- else }}
{{- printf "%s://%s:%s@%s/%s" $global.protocol $global.username $global.password $global.host $global.database -}}
{{- end -}}
{{- 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).
Expand Down
6 changes: 3 additions & 3 deletions charts/tracetest-cloud/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ data:
AGENT_HOST: "{{ .Values.config.controlPlaneUrl }}"
AGENT_PORT: "8091"
ALLOWED_EXTERNAL_REDIRECT_URIS: "https://{{ .Values.config.webUIUrl }}"
API_MONGO_DB: "tracetestcloud"
API_MONGO_DB: "{{ .Values.global.mongodb.auth.database }}"
API_PUBLIC_ROUTES: "/webhook/login,/version,/health,/robots.txt"
DASHBOARD_ADDRESS: "https://{{ .Values.config.webUIUrl }}"
DEBUG: "true"
DEV_MODE: "false"
ENTERPRISE_MODE: "false"
ENTERPRISE_MODE: "true"
KETO_ADMIN_URL: "http://keto-write.ory"
KETO_API_URL: "http://keto-read.ory"
KRATOS_ADMIN_API_URL: "http://kratos-admin.ory"
KRATOS_PUBLIC_API_URL: "http://kratos-public.ory"
NATS_URI: "nats://nats-headless.external:4222"
NATS_URI: "{{ .Values.global.nats.endpoint }}"
OAUTH_ENABLED: "false"
OSS_ENDPOINT: "http://tracetest.oss:11633"
ROOT_DOMAIN: "tracetest.io"
Expand Down
2 changes: 1 addition & 1 deletion charts/tracetest-cloud/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
{{- include "tracetest-cloud.labels" . | nindent 4 }}
type: Opaque
data:
API_MONGO_DSN: {{ .Values.config.mongodbDSN | b64enc }}
API_MONGO_DSN: {{ include "tracetest-cloud.mongodb_dsn" . | b64enc }}
POSTGRES_CONN: {{ include "tracetest-cloud.postgres_dsn" . | b64enc }}
SENDGRID_API_KEY: {{ .Values.config.sendgridApiKey | b64enc }}
HUBSPOT_API_KEY: {{ .Values.config.hubspotApiKey | b64enc }}
Expand Down
20 changes: 15 additions & 5 deletions charts/tracetest-cloud/values.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
global:
imagePullSecret: ""

mongodb:
auth:
protocol: "mongodb"
host: ""
username: ""
password: ""
database: "tracetest"
options:
retryWrites: "true"

postgres:
host: "postgres"
user: "postgres"
password: "postgres"
dbname: "tracetest"
postgres:
host: "postgres"
user: "postgres"
password: "postgres"
dbname: "tracetest"

jwtSignCert:
commonName: jwt-sign-cert
Expand Down
42 changes: 42 additions & 0 deletions charts/tracetest-dependencies/templates/mongodb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if .Values.mongodb.enabled }}
---
apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
name: {{ include "tracetest-dependencies.fullname" . }}-mongodb
spec:
members: 1
type: ReplicaSet
version: "6.0.5"
security:
authentication:
modes: ["SCRAM"]
users:
- name: {{ .Values.global.mongodb.auth.username }}
db: {{ .Values.global.mongodb.auth.database }}
passwordSecretRef: # a reference to the secret that will be used to generate the user's password
name: {{ include "tracetest-dependencies.fullname" . }}-mongodb-passwd
roles:
- name: clusterAdmin
db: admin
- name: userAdminAnyDatabase
db: admin
- name: readWrite
db: {{ .Values.global.mongodb.auth.database }}
- name: dbAdmin
db: {{ .Values.global.mongodb.auth.database }}
scramCredentialsSecretName: {{ include "tracetest-dependencies.fullname" . }}-mongodb-scram
additionalMongodConfig:
storage.wiredTiger.engineConfig.journalCompressor: zlib

# the user credentials will be generated from this secret
# once the credentials are generated, this secret is no longer required
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "tracetest-dependencies.fullname" . }}-mongodb-passwd
type: Opaque
stringData:
password: {{ .Values.global.mongodb.auth.password }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/tracetest-dependencies/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ global:
username: ""
password: ""
database: ""
mongodb:
auth:
username: "mongodb"
password: "mongodb"
database: "tracetest"

cert-manager:
enabled: true
Expand All @@ -13,6 +18,9 @@ cert-manager:
postgresql:
enabled: true

mongodb:
enabled: true

traefik:
enabled: true

Expand Down
5 changes: 5 additions & 0 deletions scripts/setup_kind_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ EOF

source $ENV_FILE

# install mongo operator
helm repo add mongodb https://mongodb.github.io/helm-charts --force-update
helm install \
community-operator mongodb/community-operator

# install cert manager
helm repo add jetstack https://charts.jetstack.io --force-update
helm install \
Expand Down
9 changes: 9 additions & 0 deletions values-kind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ global:
password: "postgres"
database: "tracetest"

mongodb:
auth:
protocol: "mongodb"
host: "ttdeps-tracetest-dependencies-mongodb-svc"
username: "mongodb"
password: "mongodb"
database: "tracetest"
options:
retryWrites: "true"

traefik:
service:
Expand Down

0 comments on commit b140b3e

Please sign in to comment.