upbound / up

The @upbound CLI
Apache License 2.0
51 stars 41 forks source link

Add up alpha migration export/import commands #409

Closed turkenh closed 6 months ago

turkenh commented 7 months ago

Description of your changes

This PR introducing the following commands as alpha to migrate control planes into Upbound managed control planes.

up alpha migration export
up alpha migration import

Migration command

❯ up alpha migration --help

Usage: up alpha migration <command>

Migrate control planes to Spaces.

The 'migration' command is designed to facilitate the seamless migration of control planes from Crossplane or Universal Crossplane
(XP/UXP) environments to Upbound's Managed Control Planes.

This tool simplifies the process of transferring your existing Crossplane configurations and states into the Upbound platform,
ensuring a smooth transition with minimal downtime.

For detailed information on each command and its options, use the '--help' flag with the specific command (e.g., 'up alpha
migration export --help').

Flags:
  -h, --help                 Show context-sensitive help.
      --format="default"     Format for get/list commands. Can be: json, yaml, default
  -v, --version              Print version and exit.
  -q, --quiet                Suppress all output.
      --pretty               Pretty print output.

      --kubeconfig=STRING    Override default kubeconfig path.

Commands:
  alpha migration export    Export the current state of a Crossplane or Universal Crossplane control plane into an archive,
                            preparing it for migration to Upbound Managed Control Planes.
  alpha migration import    Import a previously exported control plane state into an Upbound managed control plane, completing the
                            migration process.

Export Subcommand

❯ up alpha migration export --help

Usage: up alpha migration export

Export the current state of a Crossplane or Universal Crossplane control plane into an archive, preparing it for migration to
Upbound Managed Control Planes.

Usage:

    migration export [options]

The 'export' command is used to export the current state of a Crossplane or Universal Crossplane (xp/uxp) control plane into an
archive file. This file can then be used for migration to Upbound Managed Control Planes.

Use the available options to customize the export process, such as specifying the output file path, including or excluding specific
resources and namespaces, and deciding whether to pause managed resources before exporting.

Examples:

        migration export --pause-before-export
            Pauses all managed resources first and exports the control plane state to the default archive file named 'xp-state.tar.gz'.

        migration export --output=my-export.tar.gz
            Exports the control plane state to a specified file 'my-export.tar.gz'.

        migration export --include-resources="customresource.group" --include-namespaces="crossplane-system,team-a,team-b"
            Exports the control plane state to a default file 'xp-state.tar.gz', with the additional resource specified and only using provided namespaces.

Flags:
  -h, --help                                         Show context-sensitive help.
      --format="default"                             Format for get/list commands. Can be: json, yaml, default
  -v, --version                                      Print version and exit.
  -q, --quiet                                        Suppress all output.
      --pretty                                       Pretty print output.

      --kubeconfig=STRING                            Override default kubeconfig path.

      --yes                                          When set to true, automatically accepts any confirmation prompts that may
                                                     appear during the export process.
  -o, --output="xp-state.tar.gz"                     Specifies the file path where the exported archive will be saved. Defaults to
                                                     'xp-state.tar.gz'.
      --include-extra-resources=namespaces,configmaps,secrets,...
                                                     A list of extra resource types to include in the export in "resource.group"
                                                     format in addition to all Crossplane resources. By default, it includes
                                                     namespaces, configmaps, secrets.
      --exclude-resources=EXCLUDE-RESOURCES,...      A list of resource types to exclude from the export in "resource.group"
                                                     format. No resources are excluded by default.
      --include-namespaces=INCLUDE-NAMESPACES,...    A list of specific namespaces to include in the export. If not specified,
                                                     all namespaces are included by default.
      --exclude-namespaces=kube-system,kube-public,kube-node-lease,local-path-storage,...
                                                     A list of specific namespaces to exclude from the export. Defaults to
                                                     'kube-system', 'kube-public', 'kube-node-lease', and 'local-path-storage'.
      --pause-before-export                          When set to true, pauses all managed resources before starting the export
                                                     process. This can help ensure a consistent state for the export. Defaults to
                                                     false.

Import Subcommand

❯ up alpha migration import --help
Usage: up alpha migration import

Import a previously exported control plane state into an Upbound managed control plane, completing the migration process.

Usage:

    migration import [options]

The 'import' command imports a control plane state from an archive file into an Upbound managed control plane.

By default, all managed resources will be paused during the import process for possible manual inspection/validation. You can use
the --unpause-after-import flag to automatically unpause all managed resources after the import process completes.

Examples:

    migration import --input=my-export.tar.gz
        Imports the control plane state from 'my-export.tar.gz'.

    migration import --unpause-after-import
        Imports and automatically unpauses managed resources after import.

Flags:
  -h, --help                       Show context-sensitive help.
      --format="default"           Format for get/list commands. Can be: json, yaml, default
  -v, --version                    Print version and exit.
  -q, --quiet                      Suppress all output.
      --pretty                     Pretty print output.

      --kubeconfig=STRING          Override default kubeconfig path.

      --yes                        When set to true, automatically accepts any confirmation prompts that may appear during the
                                   import process.
  -i, --input="xp-state.tar.gz"    Specifies the file path of the archive to be imported. The default path is 'xp-state.tar.gz'.
      --unpause-after-import       When set to true, automatically unpauses all managed resources that were paused during the
                                   import process. This helps in resuming normal operations post-import. Defaults to false,
                                   requiring manual unpausing of resources if needed.

I have:

How has this code been tested

  1. Create a local kind cluster with Crossplane running.
  2. Install platform-ref-aws:v0.9.0
  3. Configure cloud credentials and create a cluster claim.
  4. up alpha migration export
  5. Configure Kubeconfig against an Upbound managed control plane
  6. up alpha migration import