Add support to K8s snapshots in StackGres
The objective of this issue is to gather information to implement support to K8s snapshots for StackGres.
The current URL that support from Kubernetes on snapshots is : https://kubernetes.io/docs/concepts/storage/volume-snapshots/
In Kubernetes, a VolumeSnapshot represents a snapshot of a volume on a storage system.
This document assumes that you are already familiar with Kubernetes persistent volumes.
Proposal
The proposal is to have new field useVolumeSnapshot
and volumeSnapshotClass
under SGCluster.spec.configurations.backups
section that indicate if SGBackup should create backups using VolumeSnapshot and, optionally, specify the name of the VolumeSnapshotClass to use to create the VolumeSnapshot (or use the default one). This configuration will live together with the sgStorageClass
and path
configuration since WAL archiving will continue to use it to archive WAls and is required in order to restore the SGBackup properly. Field fastVolumeSnapshot
is used to set the fast
flag when calling the pg_backup_start
function.
For SGCluster:
kind: SGCluster
spec:
configurations:
backups:
- sgStorageClass: <string>
path: <string>
useVolumeSnapshot: <boolean> # If specified SGBackup will use VolumeSnapshot to create backups. See also https://kubernetes.io/docs/concepts/storage/volume-snapshots/
volumeSnapshotClass: <string> # It indicates the name of the VolumeSnapshotClass to use to create the VolumeSnapshot. If not set the default one will be used. See also https://kubernetes.io/docs/concepts/storage/volume-snapshots/
fastVolumeSnapshot: <boolean> # If specified SGBackup will create a backup forcing a fast start (by setting parameter `fast` to `true` when calling `pg_backup_start`) that will reduce the time the backups may take at the expense of more IO usage. See also https://www.postgresql.org/docs/current/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP
For SGShardedCluster:
kind: SGShardedCluster
spec:
configurations:
backups:
- sgStorageClass: <string>
paths: [<string>]
useVolumeSnapshot: <boolean> # If specified SGBackup will use VolumeSnapshot to create backups. See also https://kubernetes.io/docs/concepts/storage/volume-snapshots/
volumeSnapshotClass: <string> # It indicates the name of the VolumeSnapshotClass to use to create the VolumeSnapshot. If not set the default one will be used. See also https://kubernetes.io/docs/concepts/storage/volume-snapshots/
fastVolumeSnapshot: <boolean> # If specified SGBackup will create a backup forcing a fast start (by setting parameter `fast` to `true` when calling `pg_backup_start`) that will reduce the time the backups may take at the expense of more IO usage. See also https://www.postgresql.org/docs/current/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP
When an SGBackup is created using a VolumeSnapshot the status of the SGBackup will have to include the backup_label
and tablespace_map
returned by pg_backup_stop
function and the name of the VolumeSnapshot created. Also, in this case, the status will not include the internalName
, backupPath
and sgBackupConfig
fields.
kind: SGBackup
status:
volumeSnapshot:
name: <string> # The name of the VolumeSnapshot
backupLabel: <string> # The content of `backup_label` column returned by `pg_backup_stop` encoded in Base64
tablespaceMap: <string> # The content of `tablespace_map` column returned by `pg_backup_stop` encoded in Base64
Acceptance criteria:
-
Describe the implementation in phases -
Describe the tests that will be implementes -
Implement the changes -
Test the feature