From 85a9d973de51b8b04a0bbd400125a9d76a2f9121 Mon Sep 17 00:00:00 2001 From: Max Wang Date: Sun, 22 Dec 2024 22:26:47 -0800 Subject: [PATCH] (core) hozer mongo replicaset setup (#756) * helm chart modifications for replicaset * use replicaset URI * add todo comments --- .github/workflows/cd-dev.yaml | 2 +- .github/workflows/cd-stage.yaml | 1 + infra/app/values.yaml | 2 +- infra/init.sh | 9 ++++----- infra/mongo/templates/pvc.yaml | 13 ------------- infra/mongo/values.yaml | 8 +++++++- 6 files changed, 14 insertions(+), 21 deletions(-) delete mode 100644 infra/mongo/templates/pvc.yaml diff --git a/.github/workflows/cd-dev.yaml b/.github/workflows/cd-dev.yaml index 1a5db781a..48a496eb9 100644 --- a/.github/workflows/cd-dev.yaml +++ b/.github/workflows/cd-dev.yaml @@ -56,7 +56,7 @@ jobs: image: tag: "${{ needs.compute-sha.outputs.sha_short }}" host: ${{ needs.compute-sha.outputs.sha_short }}.dev.stanfurdtime.com - mongoUri: mongodb://bt-dev-mongo-mongodb.bt.svc.cluster.local:27017/bt + mongoUri: mongodb://bt-dev-mongo-mongodb-0.bt-dev-mongo-mongodb-headless.bt.svc.cluster.local:27017/bt redisUri: redis://bt-dev-redis-master.bt.svc.cluster.local:6379 secrets: inherit diff --git a/.github/workflows/cd-stage.yaml b/.github/workflows/cd-stage.yaml index 582e377bf..776125663 100644 --- a/.github/workflows/cd-stage.yaml +++ b/.github/workflows/cd-stage.yaml @@ -34,4 +34,5 @@ jobs: host: staging.stanfurdtime.com mongoUri: mongodb://bt-stage-mongo-mongodb.bt.svc.cluster.local:27017/bt redisUri: redis://bt-stage-redis-master.bt.svc.cluster.local:6379 + # TODO(core): change mongoUri to replicaset secrets: inherit diff --git a/infra/app/values.yaml b/infra/app/values.yaml index 762724dde..58b1b21b9 100644 --- a/infra/app/values.yaml +++ b/infra/app/values.yaml @@ -4,7 +4,7 @@ ttl: 24 # in hours host: berkeleytime.com port: 80 -mongoUri: mongodb://bt-prod-mongo-mongodb.bt.svc.cluster.local:27017/bt +mongoUri: mongodb://bt-prod-mongo-mongodb.bt.svc.cluster.local:27017/bt # TODO(core): change to replicaset redisUri: redis://bt-prod-redis-master.bt.svc.cluster.local:6379 nodeEnv: production diff --git a/infra/init.sh b/infra/init.sh index ed9d422ae..8ec087ac3 100755 --- a/infra/init.sh +++ b/infra/init.sh @@ -53,8 +53,7 @@ helm install bt-prod-app oci://registry-1.docker.io/octoberkeleytime/bt-app --na helm install bt-stage-mongo oci://registry-1.docker.io/octoberkeleytime/bt-mongo --namespace=bt \ --version=1.0.0 \ --set mongodb.commonLabels.env=stage \ - --set hostPath=/data/stage/db \ - --set mongodb.persistence.existingClaim=bt-stage-mongo-pvc + --set hostPath=/data/stage/db helm install bt-stage-redis oci://registry-1.docker.io/octoberkeleytime/bt-redis --namespace=bt \ --version=1.0.0 \ @@ -68,6 +67,7 @@ helm install bt-stage-app oci://registry-1.docker.io/octoberkeleytime/bt-app --n --set host=staging.stanfurdtime.com \ --set mongoUri=mongodb://bt-stage-mongo-mongodb.bt.svc.cluster.local:27017/bt \ --set redisUri=redis://bt-stage-redis-master.bt.svc.cluster.local:6379 \ +# TODO(core): change mongoUri to replicaset # ========== # DEVELOPMENT @@ -76,8 +76,7 @@ helm install bt-stage-app oci://registry-1.docker.io/octoberkeleytime/bt-app --n helm install bt-dev-mongo oci://registry-1.docker.io/octoberkeleytime/bt-mongo --namespace=bt \ --version=1.0.0 \ --set mongodb.commonLabels.env=dev \ - --set hostPath=/data/dev/db \ - --set mongodb.persistence.existingClaim=bt-dev-mongo-pvc + --set hostPath=/data/dev/db helm install bt-dev-redis oci://registry-1.docker.io/octoberkeleytime/bt-redis --namespace=bt \ --version=1.0.0 \ @@ -90,6 +89,6 @@ helm install bt-dev-app oci://registry-1.docker.io/octoberkeleytime/bt-app --nam --set frontend.image.tag=dev1 \ --set backend.image.tag=dev1 \ --set host=dev1.stanfurdtime.com \ - --set mongoUri=mongodb://bt-dev-mongo-mongodb.bt.svc.cluster.local:27017/bt \ + --set mongoUri=mongodb://bt-dev-mongo-mongodb-0.bt-dev-mongo-mongodb-headless.bt.svc.cluster.local:27017/bt \ --set redisUri=redis://bt-dev-redis-master.bt.svc.cluster.local:6379 \ --set nodeEnv=development diff --git a/infra/mongo/templates/pvc.yaml b/infra/mongo/templates/pvc.yaml deleted file mode 100644 index 22e29003b..000000000 --- a/infra/mongo/templates/pvc.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ .Values.mongodb.persistence.existingClaim }} - labels: - {{- include "bt-mongo.labels" . | nindent 4 }} -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: {{ .Values.mongodb.persistence.size }} diff --git a/infra/mongo/values.yaml b/infra/mongo/values.yaml index 40bdfa820..49b85e01a 100644 --- a/infra/mongo/values.yaml +++ b/infra/mongo/values.yaml @@ -8,14 +8,20 @@ mongodb: image: tag: 7.0.5 + architecture: replicaset + arbiter: + enabled: false + replicaCount: 1 + auth: enabled: false persistence: - existingClaim: bt-prod-mongo-pvc + storageClass: manual # path in pod. should be same for all mongo pods. size: 10Gi + # required for persistence. without, data is not saved across pod restarts. volumePermissions: enabled: true