Create MigrationSchedule with storkctl
This topic explains how to create and delete a MigrationSchedule using the storkctl command-line tool.
How to use the storkctl command?
To create a MigrationSchedule using storkctl, you can use the create migrationschedules or create migrationschedule command with specific flags to define the schedule details.
In the storkctl create command, default values will be applied to all optional parameters in case you do not provide input.
Additionally, validations are implemented that will generate relevant error messages in the event of invalid or incorrect inputs to the command. For example:
error: unable to retrieve transformation default/my-resource-transformation, err: resourcetransformations.stork.libopenstorage.org "my-resource-transformation" not found
Preview resources before creating migration schedule
You can preview the resources without creating the MigrationSchedule by using the --preview or --preview-file flags with the storkctl create migrationschedule command.
These flags allow you to verify all resources, including resources that are not bound to a namespace, such as ClusterRoles and ClusterRoleBindings, before executing a migration.
To preview a migration without running it
Use the --preview flag with the usual command and parameters you would use to create the MigrationSchedule. This performs a dry run and displays the resources that would be included in the MigrationSchedule.
Example:
storkctl create migrationschedule -n <migrationNamespace> --namespaces <list of namespaces to migrate> --preview
To save the preview output to a file
Use the --preview-file <filename>.yaml flag to write the list of resources to a file for review.
Example:
storkctl create migrationschedule -n <migrationNamespace> --namespaces <list of namespaces to migrate> --previewFile=output.yaml
Create an interval-based migration schedule
Run the following command to create a migration schedule with specific configurations, including the cluster pair, namespaces to migrate, migration interval, pre-execution rule, resource transformation, and the namespace for migration resources:
storkctl create migrationschedule <migrationScheduleName> \
-c <clusterPairName> \
--namespaces <list of namespaces to migrate> \
-i <time-in-minutes> \
--pre-exec-rule <RuleName> \
--transform-spec <ResourceTransformationName> \
-n <migrationNamespace>
Example command to create a schedule policy with the specified interval:
storkctl create migrationschedule my-migration-schedule \
-c my-cluster-pair \
—namespaces namespace1,namespace2 \
-i 30 \
—pre-exec-rule mysql-pre-rule \