Skip to content

Commit 0eb4889

Browse files
authored
Extend persistent volume configuration options (#865)
Adding two additional PVC configuration options for the `sourcegraph/sourcegraph` helm chart for all stateful services: - `storageSubPath`: allows mounting a subdirectory of a volume by setting the `subPath` on the primary data volume mount for each stateful service - `storageAnnotations`: allows setting arbitrary annotations on PVC resources, for both standalone PersistentVolumeClaim resources and StatefulSet `volumeClaimTemplates` sections ### Checklist - [ ] Follow the [manual testing process](https://github.com/sourcegraph/deploy-sourcegraph-helm/blob/main/TEST.md) - [ ] Update [changelog](https://github.com/sourcegraph/deploy-sourcegraph-helm/blob/main/charts/sourcegraph/CHANGELOG.md) - [ ] Update [Kubernetes update doc](https://docs.sourcegraph.com/admin/updates/kubernetes) ### Test plan CI
1 parent 227d138 commit 0eb4889

20 files changed

Lines changed: 155 additions & 0 deletions

charts/sourcegraph/README.md

Lines changed: 22 additions & 0 deletions
Large diffs are not rendered by default.

charts/sourcegraph/templates/blobstore/blobstore.Deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ spec:
8080
volumeMounts:
8181
- name: blobstore-data
8282
mountPath: /data
83+
{{- if .Values.blobstore.storageSubPath }}
84+
subPath: {{ .Values.blobstore.storageSubPath }}
85+
{{- end }}
8386
- name: blobstore
8487
mountPath: /blobstore
8588
{{- if .Values.blobstore.extraVolumeMounts }}

charts/sourcegraph/templates/blobstore/blobstore.PersistentVolumeClaim.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ metadata:
55
labels:
66
deploy: sourcegraph
77
app.kubernetes.io/component: blobstore
8+
{{- if .Values.blobstore.storageAnnotations }}
9+
annotations:
10+
{{- toYaml .Values.blobstore.storageAnnotations | nindent 4 }}
11+
{{- end }}
812
name: blobstore
913
spec:
1014
accessModes:

charts/sourcegraph/templates/codeinsights-db/codeinsights-db.PersistentVolumeClaim.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ metadata:
55
labels:
66
app.kubernetes.io/component: codeinsights-db
77
deploy: sourcegraph
8+
{{- if .Values.codeInsightsDB.storageAnnotations }}
9+
annotations:
10+
{{- toYaml .Values.codeInsightsDB.storageAnnotations | nindent 4 }}
11+
{{- end }}
812
name: codeinsights-db
913
spec:
1014
accessModes:

charts/sourcegraph/templates/codeinsights-db/codeinsights-db.StatefulSet.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ spec:
5151
volumeMounts:
5252
- mountPath: /var/lib/postgresql/data/
5353
name: disk
54+
{{- if .Values.codeInsightsDB.storageSubPath }}
55+
subPath: {{ .Values.codeInsightsDB.storageSubPath }}
56+
{{- end }}
5457
securityContext:
5558
{{- toYaml .Values.codeInsightsDB.init.containerSecurityContext | nindent 10 }}
5659
{{- if not .Values.sourcegraph.localDevMode }}
@@ -90,6 +93,9 @@ spec:
9093
volumeMounts:
9194
- mountPath: /var/lib/postgresql/data/
9295
name: disk
96+
{{- if .Values.codeInsightsDB.storageSubPath }}
97+
subPath: {{ .Values.codeInsightsDB.storageSubPath }}
98+
{{- end }}
9399
- mountPath: /conf
94100
name: codeinsights-conf
95101
- mountPath: /var/run/postgresql

charts/sourcegraph/templates/codeintel-db/codeintel-db.PersistentVolumeClaim.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ metadata:
55
labels:
66
app.kubernetes.io/component: codeintel-db
77
deploy: sourcegraph
8+
{{- if .Values.codeIntelDB.storageAnnotations }}
9+
annotations:
10+
{{- toYaml .Values.codeIntelDB.storageAnnotations | nindent 4 }}
11+
{{- end }}
812
name: {{ default "codeintel-db" .Values.codeIntelDB.name }}
913
spec:
1014
accessModes:

charts/sourcegraph/templates/codeintel-db/codeintel-db.StatefulSet.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ spec:
5151
volumeMounts:
5252
- mountPath: /data
5353
name: disk
54+
{{- if .Values.codeIntelDB.storageSubPath }}
55+
subPath: {{ .Values.codeIntelDB.storageSubPath }}
56+
{{- end }}
5457
securityContext:
5558
{{- toYaml .Values.alpine.containerSecurityContext | nindent 10 }}
5659
{{- if not .Values.sourcegraph.localDevMode }}
@@ -101,6 +104,9 @@ spec:
101104
volumeMounts:
102105
- mountPath: /data
103106
name: disk
107+
{{- if .Values.codeIntelDB.storageSubPath }}
108+
subPath: {{ .Values.codeIntelDB.storageSubPath }}
109+
{{- end }}
104110
- mountPath: /conf
105111
name: pgsql-conf
106112
- mountPath: /var/run/postgresql

charts/sourcegraph/templates/gitserver/gitserver.StatefulSet.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ spec:
8585
name: tmpdir
8686
- mountPath: /data/repos
8787
name: repos
88+
{{- if .Values.gitserver.storageSubPath }}
89+
subPath: {{ .Values.gitserver.storageSubPath }}
90+
{{- end }}
8891
{{- if .Values.gitserver.sshSecret }}
8992
- mountPath: /home/sourcegraph/.ssh
9093
name: ssh
@@ -124,6 +127,10 @@ spec:
124127
volumeClaimTemplates:
125128
- metadata:
126129
name: repos
130+
{{- if .Values.gitserver.storageAnnotations }}
131+
annotations:
132+
{{- toYaml .Values.gitserver.storageAnnotations | nindent 8 }}
133+
{{- end }}
127134
spec:
128135
accessModes:
129136
- ReadWriteOnce

charts/sourcegraph/templates/grafana/grafana.StatefulSet.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ spec:
6565
volumeMounts:
6666
- mountPath: /var/lib/grafana
6767
name: grafana-data
68+
{{- if .Values.grafana.storageSubPath }}
69+
subPath: {{ .Values.grafana.storageSubPath }}
70+
{{- end }}
6871
- mountPath: /sg_config_grafana/provisioning/datasources
6972
name: config
7073
# Grafana is relied upon to send alerts to site admins when something is wrong with
@@ -105,6 +108,10 @@ spec:
105108
volumeClaimTemplates:
106109
- metadata:
107110
name: grafana-data
111+
{{- if .Values.grafana.storageAnnotations }}
112+
annotations:
113+
{{- toYaml .Values.grafana.storageAnnotations | nindent 8 }}
114+
{{- end }}
108115
spec:
109116
accessModes: [ "ReadWriteOnce"]
110117
resources:

charts/sourcegraph/templates/indexed-search/indexed-search.StatefulSet.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ spec:
8989
volumeMounts:
9090
- mountPath: /data
9191
name: data
92+
{{- if .Values.indexedSearch.storageSubPath }}
93+
subPath: {{ .Values.indexedSearch.storageSubPath }}
94+
{{- end }}
9295
{{- if .Values.indexedSearch.extraVolumeMounts }}
9396
{{- toYaml .Values.indexedSearch.extraVolumeMounts | nindent 8 }}
9497
{{- end }}
@@ -118,6 +121,9 @@ spec:
118121
volumeMounts:
119122
- mountPath: /data
120123
name: data
124+
{{- if .Values.indexedSearch.storageSubPath }}
125+
subPath: {{ .Values.indexedSearch.storageSubPath }}
126+
{{- end }}
121127
{{- if .Values.indexedSearchIndexer.extraVolumeMounts }}
122128
{{- toYaml .Values.indexedSearchIndexer.extraVolumeMounts | nindent 8 }}
123129
{{- end }}
@@ -147,6 +153,10 @@ spec:
147153
labels:
148154
deploy: sourcegraph
149155
name: data
156+
{{- if .Values.indexedSearch.storageAnnotations }}
157+
annotations:
158+
{{- toYaml .Values.indexedSearch.storageAnnotations | nindent 8 }}
159+
{{- end }}
150160
spec:
151161
accessModes:
152162
- ReadWriteOnce

0 commit comments

Comments
 (0)