Skip to content

Commit

Permalink
Include yorkie-mongodb to yorkie-cluster Helm Chart (#1031)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hyun98 authored Oct 19, 2024
1 parent 36d5b88 commit 9ea02a2
Show file tree
Hide file tree
Showing 19 changed files with 110 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
6 changes: 6 additions & 0 deletions build/charts/yorkie-cluster/Chart.lock
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 4 additions & 0 deletions build/charts/yorkie-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion build/charts/yorkie-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.lock
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ mongodb-sharded:

# Configuration for mongos
mongos:
namespaceOverride: mongodb
replicaCount: *mongosReplicaCount
command:
- mongos
Expand Down
32 changes: 32 additions & 0 deletions build/charts/yorkie-cluster/templates/yorkie/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
35 changes: 35 additions & 0 deletions build/charts/yorkie-cluster/templates/yorkie/role.yaml
Original file line number Diff line number Diff line change
@@ -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 -}}
16 changes: 16 additions & 0 deletions build/charts/yorkie-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 0 additions & 6 deletions build/charts/yorkie-mongodb/Chart.lock

This file was deleted.

0 comments on commit 9ea02a2

Please sign in to comment.