DigitalOcean

DigitalOcean Setup

This section shows to set up backups using DigitalOcean Spaces. You will need to have s3Cmd installed. You need to configure s3cmd following the instructions in the official docs.

Go to the API page and create a spaces key.

Create the bucket with the following characteristics (that you may change):

export DO_SPACES_BACKUP_BUCKET=stackgres-tutorial
s3cmd mb s3://${DO_SPACES_BACKUP_BUCKET}

Kubernetes Setup

Create a Kubernetes secret with the following contents:

ACCESS_KEY="**********" ## fix me
SECRET_KEY="**********" ## fix me
CLUSTER_NAMESPACE=demo
kubectl create secret generic \
  --namespace ${CLUSTER_NAMESPACE} \
  do-creds-secret \
  --from-literal=accessKeyId=${ACCESS_KEY} \
  --from-literal=secretAccessKey=${SECRET_KEY}

Having the credentials secret created, we now need to create the object storage configuration and to set the backup configuration. The object storage configuration it is governed by the SGObjectStorage CRD. This CRD allows to specify the object storage technology, required parameters, as well as a reference to the credentials secret.

Create a file sgobjectstorage-backupconfig1.yaml with the following contents:

apiVersion: stackgres.io/v1beta1
kind: SGObjectStorage
metadata:
  namespace: demo
  name: backupconfig1
spec:
  type: s3Compatible
  s3Compatible:
    bucket: 'stackgres-tutorial' ## change me if needed
    endpoint: https://nyc3.digitaloceanspaces.com
    awsCredentials:
      secretKeySelectors:
        accessKeyId: {name: 'do-creds-secret', key: 'accessKeyId'}
        secretAccessKey: {name: 'do-creds-secret', key: 'secretAccessKey'}

and deploy it to Kubernetes:

kubectl apply -f sgobjectstorage-backupconfig1.yaml

The backup configuration can be set under the section .spec.configurations.backups of the SGCluster CRD. Here we define the retention window for the automated backups and when base backups are performed. Additionally, you can define performance-related configuration of the backup process.

An example cluster configuration looks as follows:

apiVersion: stackgres.io/v1
kind: SGCluster
# [...]
spec:
  configurations:
    backups:
    - sgObjectStorage: backupconfig1
      cronSchedule: '*/5 * * * *'
      retention: 6

For this tutorial, backups are created every 5 minutes. Change the .spec.backups[0].cronSchedule parameter according to your own needs.

The above configuration will be applied when the SGCluster resource is created.