diff --git a/helm/charts/determined/templates/db-deployment.yaml b/helm/charts/determined/templates/db-deployment.yaml index 7fdf866613a..b41e82a0392 100644 --- a/helm/charts/determined/templates/db-deployment.yaml +++ b/helm/charts/determined/templates/db-deployment.yaml @@ -61,6 +61,11 @@ spec: volumes: - name: determined-db-storage persistentVolumeClaim: - claimName: determined-db-pvc-{{ .Release.Name }} + claimName: + {{ if .Values.db.claimName }} + determined-db-pvc-{{ .Values.db.claimName }} + {{- else -}} + determined-db-pvc-{{ .Release.Name }} + {{ end }} {{ end }} -{{ end}} +{{ end }} diff --git a/helm/charts/determined/templates/db-persistent-volume-claim.yaml b/helm/charts/determined/templates/db-persistent-volume-claim.yaml index 7d5c6c9fcd2..cf04cbf9a3c 100644 --- a/helm/charts/determined/templates/db-persistent-volume-claim.yaml +++ b/helm/charts/determined/templates/db-persistent-volume-claim.yaml @@ -3,7 +3,12 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: determined-db-pvc-{{ .Release.Name }} + name: + {{ if and .Release.IsUpgrade .Values.db.restoreSnapshotName }} + determined-db-pvc-{{ .Values.db.restoreSnapshotName }} + {{- else -}} + determined-db-pvc-{{ .Release.Name }} + {{ end }} namespace: {{ .Release.Namespace }} labels: app: determined-db-{{ .Release.Name }} @@ -11,6 +16,12 @@ metadata: spec: accessModes: - ReadWriteOnce + {{- if and .Release.IsUpgrade .Values.db.restoreSnapshotName }} + dataSource: + name: determined-db-snapshot-{{ .Values.db.restoreSnapshotName }} + kind: VolumeSnapshot + apiGroup: snapshot.storage.k8s.io + {{ end }} resources: requests: storage: {{ required "A valid Values.db.storageSize entry is required!" .Values.db.storageSize }} diff --git a/helm/charts/determined/templates/db-volume-snapshot-class.yaml b/helm/charts/determined/templates/db-volume-snapshot-class.yaml new file mode 100644 index 00000000000..b58850b40d0 --- /dev/null +++ b/helm/charts/determined/templates/db-volume-snapshot-class.yaml @@ -0,0 +1,6 @@ +apiVersion: snapshot.storage.k8s.io/v1 +kind: VolumeSnapshotClass +metadata: + name: determined-db-snapshot-class +driver: pd.csi.storage.gke.io +deletionPolicy: Retain diff --git a/helm/charts/determined/templates/db-volume-snapshot.yaml b/helm/charts/determined/templates/db-volume-snapshot.yaml new file mode 100644 index 00000000000..32da0e91541 --- /dev/null +++ b/helm/charts/determined/templates/db-volume-snapshot.yaml @@ -0,0 +1,19 @@ +{{- if and .Release.IsUpgrade .Values.db.snapshotName }} +apiVersion: snapshot.storage.k8s.io/v1 +kind: VolumeSnapshot +metadata: + name: determined-db-snapshot-{{ .Values.db.snapshotName }} + namespace: default + labels: + app: determined-db-{{ .Release.Name }} + release: {{ .Release.Name }} +spec: + volumeSnapshotClassName: determined-db-snapshot-class + source: + persistentVolumeClaimName: + {{ if .Values.db.claimName }} + determined-db-pvc-{{ .Values.db.claimName }} + {{- else -}} + determined-db-pvc-{{ .Release.Name }} + {{ end }} +{{ end }} diff --git a/helm/charts/determined/values.yaml b/helm/charts/determined/values.yaml index 488909382a3..30348ee8c54 100644 --- a/helm/charts/determined/values.yaml +++ b/helm/charts/determined/values.yaml @@ -196,6 +196,23 @@ db: # resourceType: # certResourceName: + # claimName refers to the persistent volume claim name for the database. + # If left undefined, a new PVC is created, named "determined-db-pvc-{{ .Release.name }}". + # Otherwise, use the pvc provided, given that it exists in the current context. + # claimName: + + # snapshotName refers to the volume snapshot name, a backup of the database's persistent volume. + # If defined, Helm will "snapshot" the DB upon its next upgrade, creating a volumeSnapshot called + # `determined-db-snapsnot-{{ .Values.snapshotName}}`. This CANNOT be the name of a persistent volume claim + # that already exists, like the `determined-db-pvc-{{Release.Name}}`. + # snapshotName: determined1 + + # restoreSnapshotName refers to the volume snapshot name which you wish to restore the DB to. + # This only applies during a Helm upgrade, and if defined. This CANNOT be the name of a PVC that + # already exists, like the {{Release.Name}}. A new persistent volume & claim will be created, named + # `determined-db-pvc-{{ .Values.restoreSnapshotName}}`, restoring the data from + # `determined-db-snapsnot-{{ .Values.restoreSnapshotName}}`. + # restoreSnapshotName: # checkpointStorage controls where checkpoints are stored. Supported types include `shared_fs`, # `gcs`, and `s3`.