Manual backup
Use the Velero add-on to manually create backups of cluster data and restore them.
- Create a Kubernetes cluster of the latest version, if not done so already.
- Make sure that you can connect to the cluster using
kubectl. - Install the OpenStack CLI, if not done yet. Make sure that you can authorize in the cloud with it.
- Install the Velero add-on, if not done yet.
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.
-
Create a manifest file specifying the storage class in the availability zone where your worker node group is located:
-
Apply the manifest in the cluster:
kubectl apply -f coffee.yamlThe manifest will create all the Kubernetes resources needed for the application to work in the
example-appnamespace. -
Make sure a disk has been created for the persistent volume:
-
Find the persistent volume created for the application:
kubectl get pv -n example-appIn the output, find the ID of the persistent volume whose
CLAIMcolumn showsexample-app/coffee-pvc. Example command output:NAME ... STATUS CLAIM ...... ... ... ... ...<PERSISTENT_VOLUME_ID> ... Bound example-app/coffee-pvc ... -
Get the ID of the disk for the created persistent volume:
kubectl describe pv <PERSISTENT_VOLUME_ID> -n example-appThe command output will contain the disk ID in the
VolumeHandleparameter. Example output:...Source:Type: CSI (a Container Storage Interface (CSI) volume source)Driver: cinder.csi.openstack.orgFSType: ...VolumeHandle: <DISK_ID>... -
Get detailed information about the disk with this ID using the OpenStack CLI:
openstack volume show <DISK_ID> --fit-width
-
-
Wait until the load balancer is assigned a floating IP address.
Periodically check the load balancer status:
kubectl get svc -n example-appThe floating IP address assigned to the load balancer should appear in the
EXTERNAL-IPcolumn. -
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.
-
Create a
coffee-backup.yamlmanifest:apiVersion: velero.io/v1kind: Backupmetadata:name: coffee-backupnamespace: velerospec:includedNamespaces:- example-app -
Apply the manifest to the cluster:
kubectl apply -f coffee-backup.yamlThis manifest creates a manual backup of the entire
example-appnamespace 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. -
(Optional) Configure a schedule for automatic backups.
-
Simulate an application failure. To do this, delete the
example-appnamespace that contains the resources required for the application to run:kubectl delete ns example-app -
Create a
coffee-restore.yamlmanifest:apiVersion: velero.io/v1kind: Restoremetadata:name: coffee-restorenamespace: velerospec:backupName: coffee-backup -
Apply the manifest to the cluster:
kubectl apply -f coffee-restore.yamlThis 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:
- Create a cluster.
- Install the Velero add-on to the cluster.
- Create and apply the
coffee-restore.yamlmanifest.
-
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.
-
Wait until a Floating IP address is assigned to the load balancer.
Periodically check the load balancer status:
kubectl get svc -n example-appThe
EXTERNAL-IPcolumn should show the Floating IP address assigned to the load balancer. -
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.
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:
-
Delete the created
example-appnamespace and its associated resources, as well as the created backup:Linux/macOSWindowskubectl delete ns example-app -
(Optional) Delete the
veleronamespace. To do this:-
Delete the created resource instances related to the addon's Custom Resource Definitions (CRD).
-
Run the command:
Linux/macOSWindowskubectl delete ns velero
-
-
Delete the backups from the bucket that was used by the Velero addon.
If necessary, also delete the bucket itself.
-
Stop the cluster you created to use it later or delete it permanently.