Migrate In Batch

Scenario

Assuming the user has a single kubernetes cluster which already has many native resource installed.

The user want to install Karmada for multi-cluster management, and hope to migrate the resource that already exist from original cluster to Karmada. It is required that the pods already exist not be affected during the process of migration, which means the relevant container not be restarted.

So, how to migrate the existing resource?

Migrate In Batch - 图1

If you only want to migrate individual resources, you can just refer to promote-legacy-workload to do it one by one.

If you want to migrate a batch of resources, you are advised to take over all resources based on resource granularity through few PropagationPolicy at first, then if you have more propagate demands based on application granularity, you can apply higher priority PropagationPolicy to preempt them.

Thus, how to take over all resources based on resource granularity? You can do as follows.

Migrate In Batch - 图2

Step one

Since the existing resources will be token over by Karmada, there is no longer need to apply the related YAML config to member cluster. That means, you can stop the corresponding operation or pipeline.

Step two

Apply all the YAML config of resources to Karmada control plane, as the ResourceTemplate of Karmada.

Step three

Edit a PropagationPolicy, and apply it to Karmada control plane. You should pay attention to two fields:

  • spec.conflictResolution: Overwritethe value must be Overwrite.
  • spec.resourceSelectors:defining which resources are selected to migrate

here we provide two examples:

Eg1. migrate all deployments

If you want to migrate all deployments from member1 cluster to Karmada, you shall apply:

  1. apiVersion: policy.karmada.io/v1alpha1
  2. kind: PropagationPolicy
  3. metadata:
  4. name: deployments-pp
  5. spec:
  6. conflictResolution: Overwrite
  7. placement:
  8. clusterAffinity:
  9. clusterNames:
  10. - member1
  11. priority: 0
  12. resourceSelectors:
  13. - apiVersion: apps/v1
  14. kind: Deployment
  15. schedulerName: default-scheduler

Eg2. migrate all services

If you want to migrate all services from member1 cluster to Karmada, you shall apply:

  1. apiVersion: policy.karmada.io/v1alpha1
  2. kind: PropagationPolicy
  3. metadata:
  4. name: services-pp
  5. spec:
  6. conflictResolution: Overwrite
  7. placement:
  8. clusterAffinity:
  9. clusterNames:
  10. - member1
  11. priority: 0
  12. resourceSelectors:
  13. - apiVersion: v1
  14. kind: Service
  15. schedulerName: default-scheduler

Step four

The rest migration operations will be finished by Karmada automatically.

PropagationPolicy Preemption and Demo

Besides, if you have more propagate demands based on application granularity, you can apply higher priority PropagationPolicy to preempt those you applied in the migration mentioned above. Detail demo you can refer to the tutorial Resource Migration