diff --git a/charts/tracetest-cloud/templates/_helpers.tpl b/charts/tracetest-cloud/templates/_helpers.tpl index 9bf6574..889af02 100644 --- a/charts/tracetest-cloud/templates/_helpers.tpl +++ b/charts/tracetest-cloud/templates/_helpers.tpl @@ -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). diff --git a/charts/tracetest-cloud/templates/configmap.yaml b/charts/tracetest-cloud/templates/configmap.yaml index 22e4279..47b4242 100644 --- a/charts/tracetest-cloud/templates/configmap.yaml +++ b/charts/tracetest-cloud/templates/configmap.yaml @@ -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" diff --git a/charts/tracetest-cloud/templates/secret.yaml b/charts/tracetest-cloud/templates/secret.yaml index 24ad2b0..1e4e200 100644 --- a/charts/tracetest-cloud/templates/secret.yaml +++ b/charts/tracetest-cloud/templates/secret.yaml @@ -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 }} diff --git a/charts/tracetest-cloud/values.yaml b/charts/tracetest-cloud/values.yaml index 7ce2d9d..7eeaee7 100644 --- a/charts/tracetest-cloud/values.yaml +++ b/charts/tracetest-cloud/values.yaml @@ -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 diff --git a/charts/tracetest-dependencies/templates/mongodb.yaml b/charts/tracetest-dependencies/templates/mongodb.yaml new file mode 100644 index 0000000..e31cdb4 --- /dev/null +++ b/charts/tracetest-dependencies/templates/mongodb.yaml @@ -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 }} diff --git a/charts/tracetest-dependencies/values.yaml b/charts/tracetest-dependencies/values.yaml index 9c5f7e1..3f7d1d7 100644 --- a/charts/tracetest-dependencies/values.yaml +++ b/charts/tracetest-dependencies/values.yaml @@ -4,6 +4,11 @@ global: username: "" password: "" database: "" + mongodb: + auth: + username: "mongodb" + password: "mongodb" + database: "tracetest" cert-manager: enabled: true @@ -13,6 +18,9 @@ cert-manager: postgresql: enabled: true +mongodb: + enabled: true + traefik: enabled: true diff --git a/scripts/setup_kind_cluster.sh b/scripts/setup_kind_cluster.sh index 52e9c18..bd4aab4 100755 --- a/scripts/setup_kind_cluster.sh +++ b/scripts/setup_kind_cluster.sh @@ -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 \ diff --git a/values-kind.yaml b/values-kind.yaml index 14c0307..969f0dd 100644 --- a/values-kind.yaml +++ b/values-kind.yaml @@ -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: