Skip to content

Commit

Permalink
install yorkie-cluster with yorkie-mongodb
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun98 committed Oct 9, 2024
1 parent fcf6fbf commit 84482a1
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 12 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-08-29T01:24:48.119979+09:00"
5 changes: 5 additions & 0 deletions build/charts/yorkie-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ version: 0.4.29
appVersion: "0.4.29"
kubeVersion: ">=1.23.0-0"

dependencies:
- name: yorkie-mongodb
version: 0.4.13
condition: yorkie-mongodb.sharded.enabled

keywords:
- yorkie
- cluster
Expand Down
8 changes: 6 additions & 2 deletions build/charts/yorkie-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ 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 yorkie

# Install yorkie cluster helm chart
helm install [RELEASE_NAME] yorkie-team/yorkie-cluster
helm install [RELEASE_NAME] yorkie-team/yorkie-cluster --set=yorkie-mongodb.sharded.enable
d=true
```

_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
34 changes: 33 additions & 1 deletion 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-db
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 "Job completed"
break
fi
echo "Waiting for 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-service-account
{{ end }}
containers:
- name: yorkie
image: "{{ .Values.yorkie.image.repository }}:{{ .Values.yorkie.image.tag | default .Chart.AppVersion }}"
Expand All @@ -54,4 +86,4 @@ spec:
port: {{ .Values.yorkie.ports.rpcPort }}
initialDelaySeconds: 10
resources:
{{ toYaml .Values.yorkie.resources | nindent 12 }}
{{ toYaml .Values.yorkie.resources | nindent 12 }}
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-status-reader
rules:
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["get", "list"]

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-db-status
namespace: {{ index .Values "yorkie-mongodb" "namespace" }}
subjects:
- kind: ServiceAccount
name: yorkie-db-service-account
namespace: {{ .Values.yorkie.namespace }}
roleRef:
kind: Role
name: db-status-reader
apiGroup: rbac.authorization.k8s.io

---

apiVersion: v1
kind: ServiceAccount
metadata:
name: yorkie-db-service-account
namespace: {{ .Values.yorkie.namespace }}
{{ end -}}
9 changes: 9 additions & 0 deletions build/charts/yorkie-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,12 @@ ratelimit:
unit: minute
requestsPerUnit: 10000
domain: yorkie-ratelimit

# Configuration for yorkie-mongodb
yorkie-mongodb:
name: mongodb
namespace: mongodb
port: 27017
clusterDomain: cluster.local
sharded:
enabled: false
6 changes: 0 additions & 6 deletions build/charts/yorkie-mongodb/Chart.lock

This file was deleted.

0 comments on commit 84482a1

Please sign in to comment.