diff --git a/charts/timescaledb-single/Chart.yaml b/charts/timescaledb-single/Chart.yaml index 84e86776..6214f604 100644 --- a/charts/timescaledb-single/Chart.yaml +++ b/charts/timescaledb-single/Chart.yaml @@ -4,7 +4,7 @@ apiVersion: v1 name: timescaledb-single description: 'TimescaleDB HA Deployment.' -version: 0.33.2 +version: 0.34.0 icon: https://cdn.iconscout.com/icon/free/png-256/timescaledb-1958407-1651618.png # appVersion specifies the version of the software, which can vary wildly, diff --git a/charts/timescaledb-single/docs/admin-guide.md b/charts/timescaledb-single/docs/admin-guide.md index fb0c228f..dd940da6 100644 --- a/charts/timescaledb-single/docs/admin-guide.md +++ b/charts/timescaledb-single/docs/admin-guide.md @@ -55,6 +55,7 @@ The following table lists the configurable parameters of the TimescaleDB Helm ch | `patroni` | Specify your specific [Patroni Configuration](https://patroni.readthedocs.io/en/latest/SETTINGS.html) | A full Patroni configuration | | `persistentVolumes..accessModes` | Persistent Volume access modes | `[ReadWriteOnce]` | | `persistentVolumes..annotations` | Annotations for Persistent Volume Claim| `{}` | +| `persistentVolumes..existingClaim` | Name of an existing pvc to use instead of creating a new Persistent Volume Claim | `""` | | `persistentVolumes..size` | Persistent Volume size | `2Gi` | | `persistentVolumes..storageClass`| Persistent Volume Storage Class | `volume.alpha.kubernetes.io/storage-class: default` | | `persistentVolumes..subPath`| Subdirectory of Persistent Volume to mount | `""` | diff --git a/charts/timescaledb-single/templates/statefulset-timescaledb.yaml b/charts/timescaledb-single/templates/statefulset-timescaledb.yaml index 7e63437d..dc4d9944 100644 --- a/charts/timescaledb-single/templates/statefulset-timescaledb.yaml +++ b/charts/timescaledb-single/templates/statefulset-timescaledb.yaml @@ -284,9 +284,10 @@ spec: - name: shared-memory mountPath: /dev/shm {{- end }} -{{- range $tablespaceName := ( .Values.persistentVolumes.tablespaces | default dict | keys ) }} +{{- range $tablespaceName, $volume := ( .Values.persistentVolumes.tablespaces | default dict ) }} - name: {{ $tablespaceName }} mountPath: {{ printf "%s/%s" (include "tablespaces_dir" $) $tablespaceName }} + subPath: {{ $volume.subPath | quote }} {{- end }} - mountPath: /etc/timescaledb/patroni.yaml subPath: patroni.yaml @@ -388,9 +389,10 @@ spec: mountPath: {{ .Values.persistentVolumes.wal.mountPath | quote }} subPath: {{ .Values.persistentVolumes.wal.subPath | quote }} {{- end }} -{{- range $tablespaceName := ( .Values.persistentVolumes.tablespaces | default dict | keys ) }} +{{- range $tablespaceName, $volume := ( .Values.persistentVolumes.tablespaces | default dict ) }} - name: {{ $tablespaceName }} mountPath: {{ printf "%s/%s" (include "tablespaces_dir" $) $tablespaceName }} + subPath: {{ $volume.subPath | quote }} {{- end }} - mountPath: /etc/pgbackrest name: pgbackrest @@ -532,11 +534,28 @@ spec: - name: storage-volume emptyDir: {} {{- end }} + {{- if and .Values.persistentVolumes.data.enabled .Values.persistentVolumes.data.existingClaim }} + - name: storage-volume + persistentVolumeClaim: + claimName: {{ .Values.persistentVolumes.data.existingClaim }} + {{- end }} + {{- if and .Values.persistentVolumes.wal.enabled .Values.persistentVolumes.wal.existingClaim }} + - name: wal-volume + persistentVolumeClaim: + claimName: {{ .Values.persistentVolumes.wal.existingClaim }} + {{- end }} + {{- range $tablespaceName, $volume := ($.Values.persistentVolumes.tablespaces | default dict ) }} + {{- if $volume.existingClaim }} + - name: {{ $tablespaceName }} + persistentVolumeClaim: + claimName: {{ $volume.existingClaim }} + {{- end }} + {{- end }} {{- if .Values.prometheus.volumes }} {{ .Values.prometheus.volumes | toYaml | nindent 6 }} {{- end }} volumeClaimTemplates: - {{- if .Values.persistentVolumes.data.enabled }} + {{- if and .Values.persistentVolumes.data.enabled (not .Values.persistentVolumes.data.existingClaim) }} - metadata: name: storage-volume annotations: @@ -551,7 +570,7 @@ spec: purpose: data-directory spec: accessModes: - {{ toYaml .Values.persistentVolumes.data.accessModes | nindent 8 }} + {{- toYaml .Values.persistentVolumes.data.accessModes | nindent 8 }} resources: requests: storage: "{{ .Values.persistentVolumes.data.size }}" @@ -563,7 +582,7 @@ spec: {{- end }} {{- end }} {{- end }} - {{- if .Values.persistentVolumes.wal.enabled }} + {{- if and .Values.persistentVolumes.wal.enabled (not .Values.persistentVolumes.wal.existingClaim) }} - metadata: name: wal-volume annotations: @@ -578,7 +597,7 @@ spec: purpose: wal-directory spec: accessModes: - {{ toYaml .Values.persistentVolumes.wal.accessModes | nindent 8 }} + {{- toYaml .Values.persistentVolumes.wal.accessModes | nindent 8 }} resources: requests: storage: "{{ .Values.persistentVolumes.wal.size }}" @@ -591,10 +610,11 @@ spec: {{- end }} {{- end }} {{- range $tablespaceName, $volume := ($.Values.persistentVolumes.tablespaces | default dict ) }} +{{- if not $volume.existingClaim }} - metadata: name: {{ $tablespaceName }} annotations: - {{ $volume.annotations | default dict | toYaml | nindent 10 }} + {{- $volume.annotations | default dict | toYaml | nindent 10 }} labels: app: {{ template "timescaledb.fullname" $ }} release: {{ $.Release.Name }} @@ -604,9 +624,10 @@ spec: purpose: tablespace spec: accessModes: - {{ $volume.accessModes | default (list "ReadWriteOnce") | toYaml | nindent 8 }} + {{- $volume.accessModes | default (list "ReadWriteOnce") | toYaml | nindent 8 }} resources: requests: storage: "{{ $volume.size }}" storageClassName: {{ $volume.storageClass | default "" }} {{- end }} +{{- end }} diff --git a/charts/timescaledb-single/values.schema.json b/charts/timescaledb-single/values.schema.json index a65ec74b..b3c50aa0 100644 --- a/charts/timescaledb-single/values.schema.json +++ b/charts/timescaledb-single/values.schema.json @@ -75,6 +75,9 @@ "enabled": { "type": "boolean" }, + "existingClaim": { + "type": "string" + }, "mountPath": { "type": "string" }, diff --git a/charts/timescaledb-single/values.schema.yaml b/charts/timescaledb-single/values.schema.yaml index dca9835f..b6582a0f 100644 --- a/charts/timescaledb-single/values.schema.yaml +++ b/charts/timescaledb-single/values.schema.yaml @@ -614,3 +614,5 @@ definitions: type: array items: type: string + existingClaim: + type: string diff --git a/charts/timescaledb-single/values.yaml b/charts/timescaledb-single/values.yaml index 00296895..2d6ccf5f 100644 --- a/charts/timescaledb-single/values.yaml +++ b/charts/timescaledb-single/values.yaml @@ -383,6 +383,8 @@ persistentVolumes: annotations: {} accessModes: - ReadWriteOnce + # Use a existing PVC which must be created manually before bound + existingClaim: "" # WAL will be a subdirectory of the data volume, which means enabling a separate # volume for the WAL files should just work for new pods. wal: @@ -396,13 +398,25 @@ persistentVolumes: annotations: {} accessModes: - ReadWriteOnce + # Use a existing PVC which must be created manually before bound + existingClaim: "" # Any tablespace mentioned here requires a volume that will be associated with it. # tablespaces: # example1: + # annotations: {} + # accessModes: + # - ReadWriteOnce + # existingClaim: "" # size: 5Gi + # subPath: "" # storageClass: gp2 # example2: + # annotations: {} + # accessModes: + # - ReadWriteOnce + # existingClaim: "" # size: 5Gi + # subPath: "" # storageClass: gp2 resources: {}