All Products
Search
Document Center

Container Service for Kubernetes:Migrate a single-cluster application to a fleet and distribute it to multiple clusters

Last Updated:Mar 26, 2026

Use the AMC command line interface to promote existing single-cluster applications into ACK One fleet management and distribute them to multiple clusters.

How it works

image
  1. Run kubectl amc promote to sync selected resources from a source cluster to the fleet.

  2. The fleet creates the resources and automatically generates a PropagationPolicy. The policy includes the clusters specified by --target-clusters and the source cluster (cluster-1).

  3. The fleet distributes the resources to each target cluster. All resources in cluster-1 and the target clusters are then managed by the fleet.

Prerequisites

Before you begin, ensure that you have:

Step 1: Create a namespace in the fleet and target clusters

Resources can only be distributed to a namespace that already exists in both the fleet and all target clusters. If the namespace already exists everywhere, skip this step.

In this example, the resources belong to the gateway-demo namespace.

  1. Using the fleet kubeconfig, create the gateway-demo namespace in the fleet.

    kubectl create ns gateway-demo
  2. Save the following YAML to a file named web-demo-ns-policy.yaml.

    apiVersion: policy.one.alibabacloud.com/v1alpha1
    kind: ClusterPropagationPolicy
    metadata:
      name: web-demo-ns-policy
    spec:
      resourceSelectors:
      - apiVersion: v1
        kind: Namespace
        name: gateway-demo
      placement:
        clusterAffinity:
          clusterNames:
          - ${cluster1_id} # Replace with your cluster ID
          - ${cluster2_id} # Replace with your cluster ID
        replicaScheduling:
          replicaSchedulingType: Duplicated
  3. Using the fleet kubeconfig, apply the manifest to create the ClusterPropagationPolicy and distribute the namespace.

    kubectl apply -f web-demo-ns-policy.yaml

Step 2: Promote resources to the fleet

Use kubectl amc promote to bring single-cluster resources under fleet management and distribute them to target clusters.

  1. Check the current state of the resources. The output shows that service1 and web-demo exist only in the gateway-demo namespace of cluster-1.

    • ADOPTION: N means the resources are not yet managed by a PropagationPolicy in the ACK One fleet.

    kubectl amc -ngateway-demo get svc -M
    kubectl amc -ngateway-demo get deployment -M

    Expected output:

    NAME       CLUSTER    CLUSTER_ALIAS   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE    ADOPTION
    service1   c8xxxxxx   cluster-1       ClusterIP   192.168.**.**   <none>        80/TCP    104m   N
    
    NAME       CLUSTER    CLUSTER_ALIAS   READY   UP-TO-DATE   AVAILABLE   AGE    ADOPTION
    web-demo   c8xxxxxx   cluster-1       2/2     2            2           104m   N
  2. Run the promote commands to place the resources under fleet management and distribute them to cluster-2. Replace ${cluster1_id} and ${cluster2_id} with your actual cluster IDs. To distribute to more than one target cluster, use comma-separated IDs: ${cluster2_id},${cluster3_id}.

    kubectl amc promote service service1 -ngateway-demo -m ${cluster1_id} --target-clusters ${cluster2_id}
    kubectl amc promote deployment web-demo -ngateway-demo -m ${cluster1_id} --target-clusters ${cluster2_id}

    Expected output:

    ResourceTemplate (gateway-demo/service1) is created successfully
    PropagationPolicy (gateway-demo/service1-67676f499c) is created successfully
    Resource "/v1, Resource=services"(gateway-demo/service1) is promoted successfully
    
    ResourceTemplate (gateway-demo/web-demo) is created successfully
    PropagationPolicy (gateway-demo/web-demo-6675b99c65) is created successfully
    Resource "apps/v1, Resource=deployments"(gateway-demo/web-demo) is promoted successfully
  3. Verify the result.

    • ADOPTION: Y confirms that both resources are now managed by the ACK One fleet.

    • service1 and web-demo are now distributed to cluster-2 and managed as a multi-cluster deployment.

    kubectl amc -ngateway-demo get svc -M
    kubectl amc -ngateway-demo get deployment -M

    Expected output:

    NAME       CLUSTER    CLUSTER_ALIAS   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE     ADOPTION
    service1   cfxxxxxx   cluster-2       ClusterIP   192.168.**.***   <none>        80/TCP    19s     Y
    service1   c8xxxxxx   cluster-1       ClusterIP   192.168.**.**    <none>        80/TCP    5h58m   Y
    
    NAME       CLUSTER    CLUSTER_ALIAS   READY   UP-TO-DATE   AVAILABLE   AGE    ADOPTION
    web-demo   c8xxxxxx   cluster-1       2/2     2            2           6h1m   Y
    web-demo   cfxxxxxx   cluster-2       2/2     2            2           24s    Y

Modify the default distribution policy

By default, kubectl amc promote creates a Duplicated PropagationPolicy (replicaSchedulingType: Duplicated), which replicates the full application to each target cluster. To view the generated policy:

kubectl get pp -ngateway-demo xx -oyaml

Expected output:

apiVersion: policy.one.alibabacloud.com/v1alpha1
kind: PropagationPolicy
metadata:
  ...
spec:
  ...
  placement:
    clusterAffinity:
      ...
    replicaScheduling:
      replicaSchedulingType: Duplicated # Default: full replica in each cluster

To use static or dynamic replica weights instead, add --auto-create-policy=false to the promote command to skip automatic policy creation, then manually configure the desired policy. For more information, see Distribution policies and differentiation policies.

What's next