From 9ea02a205730a4524096a6f09e69eba7588bb165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=ED=98=84=EC=9A=B0?= <68914294+hyun98@users.noreply.github.com> Date: Sat, 19 Oct 2024 16:56:16 +0900 Subject: [PATCH] Include yorkie-mongodb to yorkie-cluster Helm Chart (#1031) Include yorkie-mongodb to yorkie-cluster Helm chart as subchart to fully provide Yorkie cluster feature including DB layer when installing yorkie-cluster Helm chart. --- .gitignore | 2 +- build/charts/yorkie-cluster/Chart.lock | 6 ++++ build/charts/yorkie-cluster/Chart.yaml | 4 +++ build/charts/yorkie-cluster/README.md | 8 ++++- .../charts}/yorkie-mongodb/.helmignore | 0 .../charts/yorkie-mongodb/Chart.lock | 6 ++++ .../charts}/yorkie-mongodb/Chart.yaml | 2 +- .../charts}/yorkie-mongodb/README.md | 2 +- .../yorkie-mongodb/templates/NOTES.txt | 0 .../templates/sharded/_helpers.tpl | 0 .../templates/sharded/configmap.yaml | 0 .../yorkie-mongodb/templates/sharded/job.yaml | 0 .../templates/standalone/service.yaml | 0 .../templates/standalone/statefulset.yaml | 0 .../charts}/yorkie-mongodb/values.yaml | 1 + .../templates/yorkie/deployment.yaml | 32 +++++++++++++++++ .../yorkie-cluster/templates/yorkie/role.yaml | 35 +++++++++++++++++++ build/charts/yorkie-cluster/values.yaml | 16 +++++++++ build/charts/yorkie-mongodb/Chart.lock | 6 ---- 19 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 build/charts/yorkie-cluster/Chart.lock rename build/charts/{ => yorkie-cluster/charts}/yorkie-mongodb/.helmignore (100%) create mode 100644 build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.lock rename build/charts/{ => yorkie-cluster/charts}/yorkie-mongodb/Chart.yaml (96%) rename build/charts/{ => yorkie-cluster/charts}/yorkie-mongodb/README.md (98%) rename build/charts/{ => yorkie-cluster/charts}/yorkie-mongodb/templates/NOTES.txt (100%) rename build/charts/{ => yorkie-cluster/charts}/yorkie-mongodb/templates/sharded/_helpers.tpl (100%) rename build/charts/{ => yorkie-cluster/charts}/yorkie-mongodb/templates/sharded/configmap.yaml (100%) rename build/charts/{ => yorkie-cluster/charts}/yorkie-mongodb/templates/sharded/job.yaml (100%) rename build/charts/{ => yorkie-cluster/charts}/yorkie-mongodb/templates/standalone/service.yaml (100%) rename build/charts/{ => yorkie-cluster/charts}/yorkie-mongodb/templates/standalone/statefulset.yaml (100%) rename build/charts/{ => yorkie-cluster/charts}/yorkie-mongodb/values.yaml (99%) create mode 100644 build/charts/yorkie-cluster/templates/yorkie/role.yaml delete mode 100644 build/charts/yorkie-mongodb/Chart.lock diff --git a/.gitignore b/.gitignore index 63fac3f1e..6c57eea31 100644 --- a/.gitignore +++ b/.gitignore @@ -71,4 +71,4 @@ output.txt **/charts/*.tgz /build/charts/yorkie-argocd/charts/ /build/charts/yorkie-monitoring/charts/ -/build/charts/yorkie-mongodb/charts/ +/build/charts/yorkie-cluster/charts/yorkie-mongodb/charts/ diff --git a/build/charts/yorkie-cluster/Chart.lock b/build/charts/yorkie-cluster/Chart.lock new file mode 100644 index 000000000..8e934b1c3 --- /dev/null +++ b/build/charts/yorkie-cluster/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: yorkie-mongodb + repository: "" + version: 0.4.13 +digest: sha256:0c702d4ee264c8cbc9a8959d0290c12679e013ccd7a979fcbf81a8c03519b220 +generated: "2024-10-19T15:27:57.253314+09:00" diff --git a/build/charts/yorkie-cluster/Chart.yaml b/build/charts/yorkie-cluster/Chart.yaml index 15ec0268c..134dd9a3e 100644 --- a/build/charts/yorkie-cluster/Chart.yaml +++ b/build/charts/yorkie-cluster/Chart.yaml @@ -15,6 +15,10 @@ version: 0.4.29 appVersion: "0.4.29" kubeVersion: ">=1.23.0-0" +dependencies: + - name: yorkie-mongodb + version: 0.4.13 + keywords: - yorkie - cluster diff --git a/build/charts/yorkie-cluster/README.md b/build/charts/yorkie-cluster/README.md index 1ec2b262c..9b13c04dd 100644 --- a/build/charts/yorkie-cluster/README.md +++ b/build/charts/yorkie-cluster/README.md @@ -26,11 +26,17 @@ helm repo update _See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._ -## Install Helm Chart +## Install Helm Chart ```bash +# Create mongodb namespace +kubectl create namespace mongodb + # Install yorkie cluster helm chart helm install [RELEASE_NAME] yorkie-team/yorkie-cluster + +# Install yorkie cluster helm chart with standalone parameter (disable sharding) +helm install [RELEASE_NAME] yorkie-team/yorkie-cluster --set=yorkie-mongodb.sharded.enabled=false ``` _See [configuration](#configuration) below for custom installation_ diff --git a/build/charts/yorkie-mongodb/.helmignore b/build/charts/yorkie-cluster/charts/yorkie-mongodb/.helmignore similarity index 100% rename from build/charts/yorkie-mongodb/.helmignore rename to build/charts/yorkie-cluster/charts/yorkie-mongodb/.helmignore diff --git a/build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.lock b/build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.lock new file mode 100644 index 000000000..a1a73372d --- /dev/null +++ b/build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: mongodb-sharded + repository: https://charts.bitnami.com/bitnami + version: 9.0.1 +digest: sha256:3e1cba1b156f3472d720e4f08341e0f58db702302f361d1f49738fd10d60e0ff +generated: "2024-10-09T17:27:23.654759+09:00" diff --git a/build/charts/yorkie-mongodb/Chart.yaml b/build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.yaml similarity index 96% rename from build/charts/yorkie-mongodb/Chart.yaml rename to build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.yaml index 44d510740..cf54f6c98 100644 --- a/build/charts/yorkie-mongodb/Chart.yaml +++ b/build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.yaml @@ -15,6 +15,6 @@ kubeVersion: ">=1.23.0-0" dependencies: - name: mongodb-sharded - version: "7.2.2" + version: "9.0.1" repository: "https://charts.bitnami.com/bitnami" condition: sharded.enabled diff --git a/build/charts/yorkie-mongodb/README.md b/build/charts/yorkie-cluster/charts/yorkie-mongodb/README.md similarity index 98% rename from build/charts/yorkie-mongodb/README.md rename to build/charts/yorkie-cluster/charts/yorkie-mongodb/README.md index eed6956fb..19cdb6bc4 100644 --- a/build/charts/yorkie-mongodb/README.md +++ b/build/charts/yorkie-cluster/charts/yorkie-mongodb/README.md @@ -22,7 +22,7 @@ _See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentati # Create mongodb namespace kubectl create namespace mongodb -# Install yorkie monitoring helm chart +# Install yorkie mongodb helm chart helm install [RELEASE_NAME] yorkie-team/yorkie-mongodb --namespace mongodb --set=sharded.enabled=true ``` diff --git a/build/charts/yorkie-mongodb/templates/NOTES.txt b/build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/NOTES.txt similarity index 100% rename from build/charts/yorkie-mongodb/templates/NOTES.txt rename to build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/NOTES.txt diff --git a/build/charts/yorkie-mongodb/templates/sharded/_helpers.tpl b/build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/sharded/_helpers.tpl similarity index 100% rename from build/charts/yorkie-mongodb/templates/sharded/_helpers.tpl rename to build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/sharded/_helpers.tpl diff --git a/build/charts/yorkie-mongodb/templates/sharded/configmap.yaml b/build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/sharded/configmap.yaml similarity index 100% rename from build/charts/yorkie-mongodb/templates/sharded/configmap.yaml rename to build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/sharded/configmap.yaml diff --git a/build/charts/yorkie-mongodb/templates/sharded/job.yaml b/build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/sharded/job.yaml similarity index 100% rename from build/charts/yorkie-mongodb/templates/sharded/job.yaml rename to build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/sharded/job.yaml diff --git a/build/charts/yorkie-mongodb/templates/standalone/service.yaml b/build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/standalone/service.yaml similarity index 100% rename from build/charts/yorkie-mongodb/templates/standalone/service.yaml rename to build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/standalone/service.yaml diff --git a/build/charts/yorkie-mongodb/templates/standalone/statefulset.yaml b/build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/standalone/statefulset.yaml similarity index 100% rename from build/charts/yorkie-mongodb/templates/standalone/statefulset.yaml rename to build/charts/yorkie-cluster/charts/yorkie-mongodb/templates/standalone/statefulset.yaml diff --git a/build/charts/yorkie-mongodb/values.yaml b/build/charts/yorkie-cluster/charts/yorkie-mongodb/values.yaml similarity index 99% rename from build/charts/yorkie-mongodb/values.yaml rename to build/charts/yorkie-cluster/charts/yorkie-mongodb/values.yaml index 364ca8ce8..8a127e542 100644 --- a/build/charts/yorkie-mongodb/values.yaml +++ b/build/charts/yorkie-cluster/charts/yorkie-mongodb/values.yaml @@ -173,6 +173,7 @@ mongodb-sharded: # Configuration for mongos mongos: + namespaceOverride: mongodb replicaCount: *mongosReplicaCount command: - mongos diff --git a/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml b/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml index 88807bf9e..9e2029d83 100644 --- a/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml +++ b/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml @@ -32,6 +32,38 @@ spec: prometheus.io/port: "{{ .Values.yorkie.ports.profilingPort }}" prometheus.io/path: "/metrics" spec: + {{ if index .Values "yorkie-mongodb" "sharded" "enabled"}} + initContainers: + - name: wait-for-sharded-db-provision + image: bitnami/kubectl:latest + command: + - /bin/sh + - -c + - | + echo "Wait db start" + while true; do + job_status=$(kubectl get job -n $NAMESPACE $JOB_NAME -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}') + if [ "$job_status" = "True" ]; then + echo "DB provisioning Job completed successfully!" + break + fi + echo "Waiting for DB provisioning job to complete..." + sleep 5 + done + env: + - name: NAMESPACE + value: "{{ index .Values "yorkie-mongodb" "namespace" }}" + - name: JOB_NAME + value: "{{ index .Values "yorkie-mongodb" "name" }}-setup-job" + volumeMounts: + - name: kubeconfig + mountPath: /root/.kube + subPath: config + volumes: + - name: kubeconfig + emptyDir: { } + serviceAccountName: yorkie-db-provisioning-job-account + {{ end }} containers: - name: yorkie image: "{{ .Values.yorkie.image.repository }}:{{ .Values.yorkie.image.tag | default .Chart.AppVersion }}" diff --git a/build/charts/yorkie-cluster/templates/yorkie/role.yaml b/build/charts/yorkie-cluster/templates/yorkie/role.yaml new file mode 100644 index 000000000..eefa24d6f --- /dev/null +++ b/build/charts/yorkie-cluster/templates/yorkie/role.yaml @@ -0,0 +1,35 @@ +{{- if index .Values "yorkie-mongodb" "sharded" "enabled"}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + namespace: {{ index .Values "yorkie-mongodb" "namespace" }} + name: db-provisioning-job-status-reader +rules: + - apiGroups: ["batch"] + resources: ["jobs"] + verbs: ["get", "list"] + +--- + +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: read-db-provisioning-status + namespace: {{ index .Values "yorkie-mongodb" "namespace" }} +subjects: + - kind: ServiceAccount + name: yorkie-db-provisioning-job-account + namespace: {{ .Values.yorkie.namespace }} +roleRef: + kind: Role + name: db-provisioning-job-status-reader + apiGroup: rbac.authorization.k8s.io + +--- + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: yorkie-db-provisioning-job-account + namespace: {{ .Values.yorkie.namespace }} +{{ end -}} diff --git a/build/charts/yorkie-cluster/values.yaml b/build/charts/yorkie-cluster/values.yaml index 204e58d18..8b982ddb4 100644 --- a/build/charts/yorkie-cluster/values.yaml +++ b/build/charts/yorkie-cluster/values.yaml @@ -70,3 +70,19 @@ ratelimit: unit: minute requestsPerUnit: 10000 domain: yorkie-ratelimit + +# Configuration for yorkie-mongodb +yorkie-mongodb: + name: mongodb + namespace: mongodb + port: 27017 + image: + registry: docker.io + repository: mongo + tag: "6.0" + persistence: + dataSize: 1Gi + configSize: 500Mi + storageClass: standard + sharded: + enabled: true diff --git a/build/charts/yorkie-mongodb/Chart.lock b/build/charts/yorkie-mongodb/Chart.lock deleted file mode 100644 index 397448d5d..000000000 --- a/build/charts/yorkie-mongodb/Chart.lock +++ /dev/null @@ -1,6 +0,0 @@ -dependencies: -- name: mongodb-sharded - repository: https://charts.bitnami.com/bitnami - version: 7.2.2 -digest: sha256:ae306fa705473ca5e99f02fcca27ebb5900cf4bdf4357472f8b5006c9c4fca24 -generated: "2024-01-23T20:44:36.400805+09:00"