open shift backup etcc and velero - unix1998/technical_notes GitHub Wiki
OpenShift provides several tools and approaches to backup and restore the cluster configuration and state. One of the most commonly used tools for this purpose is Velero (formerly known as Heptio Ark). Velero can backup and restore Kubernetes (and OpenShift) cluster resources and persistent volumes. Additionally, OpenShift 4.x also includes the Cluster Version Operator (CVO) which helps manage and back up cluster state.
Velero is a powerful tool for managing backups and restores of your Kubernetes cluster. It can back up the entire cluster, including namespaces, configuration, and persistent volumes.
-
Install Velero CLI: Download and install the Velero CLI from the Velero GitHub releases page.
-
Install Velero Server: Deploy the Velero server components in your OpenShift cluster. You can follow the installation guide specific to your cloud provider (AWS, GCP, Azure, etc.) or use a generic provider.
Example for AWS:
velero install \ --provider aws \ --bucket <YOUR_BUCKET_NAME> \ --secret-file <YOUR_SECRET_FILE> \ --backup-location-config region=<YOUR_REGION> \ --snapshot-location-config region=<YOUR_REGION>
-
Create a Backup: Use Velero to create a backup of your OpenShift cluster resources.
velero backup create <BACKUP_NAME> --include-namespaces <NAMESPACE>
For a full cluster backup, omit the
--include-namespaces
flag. -
Restore a Backup: Use Velero to restore from a backup.
velero restore create --from-backup <BACKUP_NAME>
In OpenShift 4.x, the etcd database is crucial as it stores the entire cluster state. Regular backups of etcd are essential for disaster recovery.
-
Export the KUBECONFIG: Ensure you have access to the OpenShift cluster:
export KUBECONFIG=/path/to/kubeconfig
-
Run the etcd Backup Script: OpenShift provides a script to back up etcd:
oc adm cluster-backup /path/to/backup/dir
This script creates a backup of the etcd database and cluster state, including resources managed by the Cluster Version Operator (CVO).
-
Shutdown the Cluster: Ensure the cluster is not running to prevent any changes during the restore process.
-
Run the etcd Restore Script: Use the provided script to restore etcd from a backup:
oc adm cluster-restore /path/to/backup/dir
- Velero: A flexible tool for backing up and restoring Kubernetes and OpenShift clusters, including persistent volumes.
- etcd Backup/Restore in OpenShift 4.x: Ensures the cluster state and configuration are backed up and can be restored in case of failure.
Using these tools, you can ensure that your OpenShift cluster’s configuration and state are securely backed up and can be restored, providing a robust disaster recovery strategy.