Configure remote MariaDB backups

TechPreview

By default, MOSK stores the MariaDB backups locally in the cluster storage. The mariadb-phy-backup-data PersistentVolumeClaim (PVC), where the backups are stored, is provisioned by StorageClass described by the spec.persistent_volume_storage_class spec of the OpenstackDeployment custom resource (CR).

Alternatively, MOSK provides you with a capability to create remote backups using an external storage. This section contains the details on how you, as a cloud operator, can configure the Network File System (NFS) back end for the OpenStack backup data.

Requirements

  • A preconfigured NFS server with NFS share that a Unix backup and restore user has access to. By default, it is the same user that runs MySQL server in a MariaDB image.

    To get the Unix user ID, run:

    kubectl -n openstack get cronjob mariadb-phy-backup -o jsonpath='{.spec.jobTemplate.spec.template.spec.securityContext.runAsUser}'
    

    Note

    Verify that the NFS server is accessible through the network from all of the OpenStack control plane nodes of the cluster.

  • The nfs-common package installed on all OpenStack control plane nodes.

Limitations

  • Only NFS Unix authentication is supported.

  • Removal of the NFS persistent volume does not automatically remove the data.

  • No validation options. If mount options are specified incorrectly in the OpenStackDeployment CR, the mount command fails on the creation of a backup runner pod.

Configure a remote MariaDB backup

  1. If OpenStack was deployed with the default back end, proceed with the following. Otherwise, skip this step.

    1. Save the backup data in a storage different from the mariadb-phy-backup-data PVC.

    2. Remove the mariadb-phy-backup-data PVC manually:

      kubectl -n openstack delete pvc mariadb-phy-backup-data
      
  2. Enable the NFS back end in the OpenStackDeployment object by editing the backup section of the OpenStackDeployment CR as follows:

    spec:
      features:
        database:
          backup:
            enabled: true
            backend: pv_nfs
            pv_nfs:
              server: <ip-address/dns-name-of-the-server>
              path: <path-to-the-share-folder-on-the-server>
    
  3. Optional. Set the required mount options for the NFS mount command. You can set as many options of mount as you need. For example:

    spec:
      services:
        database:
          mariadb:
            values:
              volume:
                phy_backup:
                  nfs:
                    mountOptions:
                      - "nfsvers=4"
                      - "hard"
    
  4. Verify the mariadb-phy-backup-data PVC and NFS persistent volume (PV):

    kubectl -n openstack get pvc mariadb-phy-backup-data -o wide
    
    kubectl -n openstack get pv mariadb-phy-backup-data-nfs-pv -o yaml
    

    An example of a positive system response:

    NAME                      STATUS   VOLUME                           CAPACITY   ACCESS MODES   STORAGECLASS   AGE     VOLUMEMODE
    mariadb-phy-backup-data   Bound    mariadb-phy-backup-data-nfs-pv   20Gi       RWO                           5m40s   Filesystem
    
    apiVersion: v1
    kind: PersistentVolume
    metadata:
      annotations:
        meta.helm.sh/release-name: openstack-mariadb
        meta.helm.sh/release-namespace: openstack
      <<<skipped>>>>
      name: mariadb-phy-backup-data-nfs-pv
      resourceVersion: "2279204"
      uid: 60db9f89-afc4-417b-bf44-8acab844f17e
    spec:
      accessModes:
      - ReadWriteOnce
      capacity:
        storage: 20Gi
      claimRef:
        apiVersion: v1
        kind: PersistentVolumeClaim
        name: mariadb-phy-backup-data
        namespace: openstack
        resourceVersion: "2279201"
        uid: e0e08d73-e56f-425a-ad4e-e5393aa3cdc1
      mountOptions:
      - nfsvers=4
      - hard
      nfs:
        path: /
        server: 10.10.0.116
      persistentVolumeReclaimPolicy: Retain
      volumeMode: Filesystem
    status:
      phase: Bound
    

Switch back to the local MariaDB database backup

  1. Remove NFS PVC and PV:

    kubectl -n openstack delete pvc mariadb-phy-backup-data
    
    kubectl -n openstack delete pv mariadb-phy-backup-data-nfs-pv
    
  2. Re-enable the local backup in the OpenStackDeployment CR:

    spec:
      features:
        database:
          backup:
            enabled: true
            backend: pvc
    
  3. Verify that the mariadb-phy-backup-data PVC uses the default PV:

    kubectl -n openstack get pvc mariadb-phy-backup-data
    

    An example of a positive system response:

    NAME                      STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS              AGE
    mariadb-phy-backup-data   Bound    pvc-a4f6e24b-c05b-4a76-bca2-bb6a5c8ef5b5   20Gi       RWO            mirablock-k8s-block-hdd   80m