Skip to content

Commit

Permalink
Make storage provisions configurable. (#263)
Browse files Browse the repository at this point in the history
Persistent volume helm configuration
  • Loading branch information
soujanyanmbri committed Aug 21, 2024
1 parent d52e1d4 commit 3fd0372
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,4 @@ jobs:
run: |
cd services/web
npm install
npm run lint
npm run lint
3 changes: 2 additions & 1 deletion deploy/helm/templates/mongodb/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ spec:
volumes:
- name: mongodb-data
persistentVolumeClaim:
claimName: {{ .Values.mongodb.pvc.name }}
claimName: {{ .Values.mongodb.storage.pvc.name }}

34 changes: 26 additions & 8 deletions deploy/helm/templates/mongodb/storage.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
kind: PersistentVolumeClaim
{{- if eq .Values.mongodb.storage.type "manual" }}
apiVersion: v1

kind: PersistentVolume
metadata:
name: {{ .Values.mongodb.storage.pv.name }}
labels:
release: {{ .Release.Name }}
{{- toYaml .Values.mongodb.storage.pv.labels | nindent 4 }}
spec:
storageClassName: {{ .Values.mongodb.storage.type }}
capacity:
storage: {{ .Values.mongodb.storage.pv.resources.storage }}
accessModes:
- ReadWriteOnce
hostPath:
path: {{ .Values.mongodb.storage.pv.hostPath }}
---
{{- end }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.mongodb.pvc.name }}
name: {{ .Values.mongodb.storage.pvc.name }}
labels:
release: {{ .Release.Name }}
{{- toYaml .Values.mongodb.pvc.labels | nindent 4 }}

{{- toYaml .Values.mongodb.storage.pvc.labels | nindent 4 }}
spec:
#storageClassName: local-path
{{- if ne .Values.mongodb.storage.type "default" }}
storageClassName: {{ .Values.mongodb.storage.type }}
{{- end }}
accessModes:
- ReadWriteOnce

resources:
{{- toYaml .Values.mongodb.pvc.resources | nindent 4 }}
{{- toYaml .Values.mongodb.storage.pvc.resources | nindent 4 }}

2 changes: 1 addition & 1 deletion deploy/helm/templates/postgres/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ spec:
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: {{ .Values.postgresdb.pvc.name }}
claimName: {{ .Values.postgresdb.storage.pvc.name }}
33 changes: 25 additions & 8 deletions deploy/helm/templates/postgres/storage.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
kind: PersistentVolumeClaim
{{- if eq .Values.postgresdb.storage.type "manual" }}
apiVersion: v1

kind: PersistentVolume
metadata:
name: {{ .Values.postgresdb.storage.pv.name }}
labels:
release: {{ .Release.Name }}
{{- toYaml .Values.postgresdb.storage.pv.labels | nindent 4 }}
spec:
storageClassName: {{ .Values.postgresdb.storage.type }}
capacity:
storage: {{ .Values.postgresdb.storage.pv.resources.storage }}
accessModes:
- ReadWriteOnce
hostPath:
path: {{ .Values.postgresdb.storage.pv.hostPath }}
---
{{- end }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.postgresdb.pvc.name }}
name: {{ .Values.postgresdb.storage.pvc.name }}
labels:
release: {{ .Release.Name }}
{{- toYaml .Values.postgresdb.pvc.labels | nindent 4 }}

{{- toYaml .Values.postgresdb.storage.pvc.labels | nindent 4 }}
spec:
#storageClassName: local-path
{{- if ne .Values.postgresdb.storage.type "default" }}
storageClassName: {{ .Values.postgresdb.storage.type }}
{{- end }}
accessModes:
- ReadWriteOnce

resources:
{{- toYaml .Values.postgresdb.pvc.resources | nindent 4 }}
{{- toYaml .Values.postgresdb.storage.pvc.resources | nindent 4 }}
37 changes: 37 additions & 0 deletions deploy/helm/values-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
mongodb:
storage:
type: "manual"
pv:
name: mongodb-pv
labels:
app: mongodb
resources:
storage: 2Gi
hostPath: /mnt/test
accessModes: ReadWriteOnce
pvc:
name: mongodb-pv-claim
labels:
app: mongodb
resources:
requests:
storage: 2Gi

postgresdb:
storage:
type: "manual"
pv:
name: postgres-pv
labels:
app: postgresdb
resources:
storage: 2Gi
hostPath: /mnt/test
pvc:
name: postgres-pv-claim
labels:
app: postgresdb
accessModes: ReadWriteOnce
resources:
requests:
storage: 2Gi
48 changes: 34 additions & 14 deletions deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,23 @@ mongodb:
mongoPassword: crapisecretpassword
mongoDbName: crapi
mongoUri: "admin:crapisecretpassword@mongodb:27017"
pvc:
name: mongodb-pv-claim
labels:
app: mongodb
resources:
requests:
storage: 2Gi
storage:
# type: "manual"
# pv:
# name: mongodb-pv
# labels:
# app: mongodb
# resources:
# storage: 2Gi
# hostPath: /mnt/test
type: "default"
pvc:
name: mongodb-pv-claim
labels:
app: mongodb
resources:
requests:
storage: 2Gi
serviceSelectorLabels:
app: mongodb
podLabels:
Expand Down Expand Up @@ -221,13 +231,23 @@ postgresdb:
postgresUser: admin
postgresPassword: crapisecretpassword
postgresDbName: crapi
pvc:
name: postgres-pv-claim
labels:
app: postgresdb
resources:
requests:
storage: 2Gi
storage:
# type: "manual"
# pv:
# name: postgres-pv
# labels:
# app: postgresdb
# resources:
# storage: 2Gi
# hostPath: /mnt/test
type: "default"
pvc:
name: postgres-pv-claim
labels:
app: postgresdb
resources:
requests:
storage: 2Gi
serviceSelectorLabels:
app: postgresdb
podLabels:
Expand Down
11 changes: 10 additions & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,22 @@ You can change the smtp configuration if required however all emails with domain
```
git clone [REPOSITORY-URL]
```

2. Install the helm chart

Inorder to manually mount the data to a specific location, hostPath should be updated in values-pv.yaml, and used to install the helm charts.

```
cd deploy/helm
helm install --namespace crapi crapi . --values values-pv.yaml
```
Otherwise install the helm chart normally.
```
cd deploy/helm
helm install --namespace crapi crapi . --values values.yaml
```

3. If using minikube, create a tunnel to initialize the LoadBalancers
```
minikube tunnel --alsologtostderr
Expand Down
13 changes: 13 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,16 @@ systemctl cat docker.service
It will tell you where the docker service file is located. Then edit `/lib/systemd/system/docker.service` with your favorite text editor: append `NetworkManager-wait-online.service` to line 4 (that line should start with the word `After=`)

Then run `systemctl daemon-reload` to update your changes to the service file.

---

**5. Problem:** Issues while using hostPath to manually mount the data:

ERROR: 0/1 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling

To fix this issue, delete the existing persistent volumes, and start clean.
```Shell
❯ kubectl get pv

❯ kubectl delete pv {pv_names}
```

0 comments on commit 3fd0372

Please sign in to comment.