ironcore-dev / metal-operator

Kubernetes operator for automating bare metal server discovery and provisioning
Apache License 2.0
10 stars 4 forks source link

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

Open afritzler opened 6 days ago

afritzler commented 6 days ago

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

Key Objectives

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:

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

Additional Considerations

afritzler commented 6 days ago

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