The migrate-controller component is developed by Alibaba Cloud based on the open source project Velero. You can use this component to migrate Kubernetes applications. This topic describes how to use migrate-controller to back up and restore applications in a Container Service for Kubernetes (ACK) cluster.
Prerequisites
Back up applications
You can use the Velero tool of migrate-controller to back up all resources in one
or more specified namespaces of an ACK cluster. Command:
velero backup create <BACKUP NAME> --include-namespaces <INCLUDE NAMESPACES>
The following examples show how to back up all resources in one namespace and all
resources in two namespaces by running commands:
- Back up applications in the nginx-examples namespace:
velero backup create backup-nginx --include-namespaces nginx-examples
- Back up applications in the nginx-examples namespace and wordpress namespace:
velero backup create backup-nginx-and-wordpress --include-namespaces nginx-examples,wordpress
Note The preceding operations do not back up the data of persistent volumes (PVs) that
are mounted to the applications. Instead, only orchestration files in the JSON format
are backed up.
If you want to back up the PVs, perform the following steps:
Back up applications at a scheduled time
To back up applications at a scheduled time, run the following command to create a
scheduled backup task:
velero schedule create <NAME> --include-namespaces <NAMESPACE> --schedule "SCHEDULE"
The following examples show how to back up applications every 7 days and every 24
hours by running commands:
- Create the nginx-app-with-pv-schedule-01 scheduled task to back up applications in
the nginx-examples namespace every 7 days:
velero schedule create nginx-app-with-pv-schedule-01 --include-namespaces nginx-examples --schedule "0 7 * * *"
- Create the nginx-app-with-pv-schedule-02 scheduled task to back up applications in
the nginx-examples namespace every 24 hours:
velero schedule create nginx-app-with-pv-schedule-01 --include-namespaces nginx-examples --schedule "@every 24h"
Restore applications
This example describes how to restore applications after the namespace to which the applications belong is deleted.