VK Cloud logo

Manual backup

Use the Velero add-on to manually create backups of cluster data and restore them.

Preparation steps

  1. Create a Kubernetes cluster of the latest version, if not done so already.
  2. Make sure that you can connect to the cluster using kubectl.
  3. Install the OpenStack CLI, if not done yet. Make sure that you can authorize in the cloud with it.
  4. Install the Velero add-on, if not done yet.

1. Create an application

To get familiar with creating a backup and restoring from it, create the coffee demo application. A persistent volume will be attached to this application.

  1. Create a manifest file specifying the storage class in the availability zone where your worker node group is located:

  2. Apply the manifest in the cluster:

    kubectl apply -f coffee.yaml

    The manifest will create all the Kubernetes resources needed for the application to work in the example-app namespace.

  3. Make sure a disk has been created for the persistent volume:

    1. Find the persistent volume created for the application:

      kubectl get pv -n example-app

      In the output, find the ID of the persistent volume whose CLAIM column shows example-app/coffee-pvc. Example command output:

      NAME                    ...   STATUS   CLAIM                    ......                     ...   ...      ...                      ...<PERSISTENT_VOLUME_ID>  ...   Bound    example-app/coffee-pvc   ...
    2. Get the ID of the disk for the created persistent volume:

      kubectl describe pv <PERSISTENT_VOLUME_ID> -n example-app

      The command output will contain the disk ID in the VolumeHandle parameter. Example output:

      ...Source:    Type:          CSI (a Container Storage Interface (CSI) volume source)    Driver:        cinder.csi.openstack.org    FSType:        ...    VolumeHandle:  <DISK_ID>    ...
    3. Get detailed information about the disk with this ID using the OpenStack CLI:

      openstack volume show <DISK_ID> --fit-width
  4. Wait until the load balancer is assigned a floating IP address.

    Periodically check the load balancer status:

    kubectl get svc -n example-app

    The floating IP address assigned to the load balancer should appear in the EXTERNAL-IP column.

  5. Make sure NGINX responds to requests:

    curl <FLOATING_IP_ADDRESS_OF_LOAD_BALANCER>

    Expected output:

    The coffee pod says Hello World to everyone! This file is located on the dynamically claimed Cinder ReadWriteOnce persistent volume.

2. Create an application backup

  1. Create a coffee-backup.yaml manifest:

    apiVersion: velero.io/v1kind: Backupmetadata:  name: coffee-backup  namespace: velerospec:  includedNamespaces:    - example-app
  2. Apply the manifest to the cluster:

    kubectl apply -f coffee-backup.yaml

    This manifest creates a manual backup of the entire example-app namespace that contains the resources required for the application to run. The lifetime of the created backup is 72 hours by default. After this time expires, the backup will be deleted.

  3. (Optional) Configure a schedule for automatic backups.

3. Restore the application from a backup

  1. Simulate an application failure. To do this, delete the example-app namespace that contains the resources required for the application to run:

    kubectl delete ns example-app
  2. Create a coffee-restore.yaml manifest:

    apiVersion: velero.io/v1kind: Restoremetadata:  name: coffee-restore  namespace: velerospec:  backupName: coffee-backup
  3. Apply the manifest to the cluster:

    kubectl apply -f coffee-restore.yaml

    This manifest restores resources from the backup created earlier. The data is restored to the same cluster where the backup was performed. If you need to restore the data to a new cluster:

    1. Create a cluster.
    2. Install the Velero add-on to the cluster.
    3. Create and apply the coffee-restore.yaml manifest.
  4. Remove the annotation with the load balancer identifier that remained after the backup was restored:

    kubectl -n example-app annotate service coffee-svc loadbalancer.openstack.org/load-balancer-id-

    After that, a new load balancer will be created.

  5. Wait until a Floating IP address is assigned to the load balancer.

    Periodically check the load balancer status:

    kubectl get svc -n example-app

    The EXTERNAL-IP column should show the Floating IP address assigned to the load balancer.

  6. Make sure that NGINX responds to requests:

    curl <LOAD_BALANCER_FLOATING_IP_ADDRESS>

    Expected output:

    The coffee pod says Hello World to everyone! This file is located on the dynamically claimed Cinder ReadWriteOnce persistent volume.

Delete unused resources

A running cluster is billed and consumes computing resources. If you no longer need the Kubernetes resources created to test backups with the Velero addon, delete them:

  1. Delete the created example-app namespace and its associated resources, as well as the created backup:

    kubectl delete ns example-app
  2. (Optional) Delete the velero namespace. To do this:

    1. Delete the created resource instances related to the addon's Custom Resource Definitions (CRD).

    2. Run the command:

      kubectl delete ns velero
  3. Delete the backups from the bucket that was used by the Velero addon.

    If necessary, also delete the bucket itself.

  4. Stop the cluster you created to use it later or delete it permanently.

Was this article helpful?