Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metalctl CLI with move Command to Migrate CRDs and CRs Between Clusters #146

Open
afritzler opened this issue Oct 21, 2024 · 2 comments · May be fixed by #162
Open

Add metalctl CLI with move Command to Migrate CRDs and CRs Between Clusters #146

afritzler opened this issue Oct 21, 2024 · 2 comments · May be fixed by #162
Assignees
Labels
enhancement New feature or request

Comments

@afritzler
Copy link
Member

afritzler commented Oct 21, 2024

Description

We are introducing a new CLI tool called metalctl to interact with the metal-operator as part of our metal-operator ecosystem. The initial command to be implemented is the move command, which will facilitate the migration of Custom Resource Definitions (CRDs) and Custom Resources (CRs) related to metal-operator from one Kubernetes cluster to another.

Goal

  • Create a new CLI utility called metalctl.
  • Integrate the move command to migrate all metal-operator related CRDs and CRs between two clusters.

Key Objectives

  • Ensure seamless migration of metal-operator CRDs and CRs.
  • Ensure the migration process handles dependency order (CRDs must be moved present before CRs).
  • Handle failure scenarios gracefully with appropriate error messages and rollback functionality.

Command Details

Command: move

The move command will enable users to specify a source and target Kubernetes cluster for migrating CRDs and CRs associated with the metal-operator.

Command Options:

  • --source-kubeconfig (required): Path to the kubeconfig of the source cluster.
  • --target-kubeconfig (required): Path to the kubeconfig of the target cluster.
    - --crds-only (optional): Flag to migrate only the CRDs without CRs.
    - --crs-only (optional): Flag to migrate only the CRs without CRDs.
  • --namespace (optional): Specify a namespace to filter CRDs and CRs to migrate. Defaults to all namespaces if not specified.
  • --dry-run (optional): Perform a dry run to show what would be moved without executing the migration.
  • --verbose (optional): Enable verbose logging for detailed output during migration.

Example Usage:

metalctl move --source-kubeconfig=~/.kube/source-cluster.yaml \
              --target-kubeconfig=~/.kube/target-cluster.yaml \
              --namespace=metal-namespace

Steps in the move Process:

  1. Validate Input: Verify the presence of both source-kubeconfig and target-kubeconfig.
  2. Fetch CRDs from Source Cluster: Use the source kubeconfig to list all CRDs related to the metal-operator.
  3. Apply CRDs to Target Cluster: Use the target kubeconfig to apply the CRDs. Ensure idempotency in case they already exist.
  4. Fetch CRs from Source Cluster: Fetch all CRs of the metal-operator from the source cluster.
  5. Apply CRs to Target Cluster: Apply all CRs to the target cluster.
  6. Verify Migration: Ensure the CRDs and CRs have been successfully created in the target cluster.
  7. Error Handling and Rollback: If any step fails, provide detailed error messages and rollback any partial migrations where applicable.

Definition of Done

  • A new CLI tool metalctl is created with a functional move command.
  • The move command successfully migrates metal-operator CRDs and CRs between clusters.
  • Support for dry-run, crds-only, crs-only, and namespace options.
  • Detailed documentation for using the move command is included.
  • Adequate test coverage for the move functionality, including unit tests and integration tests.

Additional Considerations

  • Future commands for metalctl can include operations like listing or deleting resources, which should be planned for in the CLI structure.
  • Console access: Add a console command to access the serial console of a server. This will allow users to remotely view or interact with a server's console for debugging and management purposes.
@afritzler afritzler added the enhancement New feature or request label Oct 21, 2024
@afritzler afritzler moved this from Backlog to Ready in Metal Automation Oct 21, 2024
@afritzler
Copy link
Member Author

@hardikdr we might need something like that in the boot-operator project as well.

@Nuckal777 Nuckal777 self-assigned this Oct 21, 2024
@SchwarzM
Copy link

please use : https://github.com/spf13/cobra as scaffold for the cli as well as a configurable structured logging facility

@SzymonSAP SzymonSAP linked a pull request Nov 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

3 participants