All Products
Search
Document Center

Container Service for Kubernetes:Get started with application distribution

Last Updated:Jun 24, 2026

Use ACK One Fleet application distribution to deploy applications across associated clusters with a PropagationPolicy — no Git repositories required.

You will:

  • Create an application on a Fleet instance

  • Define a PropagationPolicy for multi-cluster distribution

  • (Optional) Applied an OverridePolicy for per-cluster customization

  • Verify, update, and clean up distributed resources

Prerequisites

Ensure that you have:

(Optional) Step 1: Create a namespace on the Fleet instance

Create the namespace if it does not exist on the Fleet instance.

Create a namespace named demo:

kubectl create namespace demo

Step 2: Create an application on the Fleet instance

Fleet distributes ConfigMaps, Deployments, and Services. This example uses an NGINX Deployment.

  1. Create web-demo.yaml with the following content:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      namespace: demo
      name: web-demo
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: web-demo
      template:
        metadata:
          labels:
            app: web-demo
        spec:
          containers:
          - name: nginx
            image: registry-cn-hangzhou.ack.aliyuncs.com/acs/web-demo:0.5.0
            ports:
            - containerPort: 80
  2. Deploy the application:

    kubectl apply -f web-demo.yaml

Step 3: Create a PropagationPolicy to distribute the application

A PropagationPolicy defines which resources to distribute and to which clusters. Once applied, the controller automatically pushes matching resources to the target clusters.

This example distributes the Deployment to two clusters in Duplicated mode — each cluster runs three replicas independently.

  1. Get the member cluster IDs:

    kubectl get mcl

    The output is similar to:

    NAME                                HUB ACCEPTED   MANAGED CLUSTER URLS   JOINED   AVAILABLE   AGE
    cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   true                                  True     True        3d23h
    cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   true                                  True     True        5d21h
  2. Create propagationpolicy.yaml with the following content. Replace ${cluster1-id} and ${cluster2-id} with your cluster IDs.

    ClusterPropagationPolicy distributes cluster-scoped resources (such as Namespaces). PropagationPolicy distributes namespace-scoped resources and selects only within its own namespace.
    apiVersion: policy.one.alibabacloud.com/v1alpha1
    kind: ClusterPropagationPolicy
    metadata:
      name: web-demo
    spec:
      resourceSelectors:
      - apiVersion: v1
        kind: Namespace
        name: demo
      placement:
        clusterAffinity:
          clusterNames:
          - ${cluster1-id} # The ID of your cluster.
          - ${cluster2-id} # The ID of your cluster.
        replicaScheduling:
          replicaSchedulingType: Duplicated
    ---
    apiVersion: policy.one.alibabacloud.com/v1alpha1
    kind: PropagationPolicy
    metadata:
      name: web-demo
      namespace: demo
    spec:
      preserveResourcesOnDeletion: true # When true, deleting resources from the Fleet instance keeps them in the member cluster. Set to false to delete them together.
      resourceSelectors:
      - apiVersion: apps/v1
        kind: Deployment
        name: web-demo
        namespace: demo
      placement:
        clusterAffinity:
          clusterNames:
          - ${cluster1-id} # The ID of your cluster.
          - ${cluster2-id} # The ID of your cluster.
        replicaScheduling:
          replicaSchedulingType: Duplicated

    Key parameters are listed below. The full parameter list is in PropagationPolicy.

    Parameter Description Example
    resourceSelectors Resources to distribute. Match by apiVersion, kind, name, namespace, or labelSelector. Select the web-demo Deployment in the demo namespace.
    placement.clusterAffinity Target clusters for distribution. Enter cluster IDs, not cluster names. ${cluster1-id}, ${cluster2-id}
    replicaScheduling.replicaSchedulingType Scheduling mode. Duplicated replicates the full replica count (defined by spec.replicas) to each cluster. Duplicated
  3. Apply the PropagationPolicy:

    kubectl apply -f propagationpolicy.yaml

(Optional) Step 4: Create an OverridePolicy to customize per-cluster configuration

An OverridePolicy modifies resource configuration before deployment, letting you tailor settings for individual clusters.

This example targets ${cluster2-id} with two changes:

  • Reduces replicas from 3 to 1

  • Prepends a registry prefix to the image

Before applying the OverridePolicy, the Deployment on ${cluster2-id} has:

spec:
  replicas: 3
  ...
  containers:
    - image: registry-cn-hangzhou.ack.aliyuncs.com/acs/web-demo:0.5.0

After applying the OverridePolicy, the Deployment on ${cluster2-id} becomes:

spec:
  replicas: 1
  ...
  containers:
    - image: {{Registry}}/registry-cn-hangzhou.ack.aliyuncs.com/acs/web-demo:0.5.0
  1. Create overridepolicy.yaml with the following content:

    apiVersion: policy.one.alibabacloud.com/v1alpha1
    kind: OverridePolicy
    metadata:
      name: example
      namespace: demo
    spec:
      resourceSelectors:
        - apiVersion: apps/v1
          kind: Deployment
          name: web-demo
      overrideRules:
        - targetCluster:
            clusterNames:
              - ${cluster2-id}
          overriders:
            plaintext:
              - operator: replace
                path: /spec/replicas
                value: 1
            imageOverrider:
              - component: Registry
                operator: add
                value: {{Registry}}

    Key parameters are listed below. The full parameter list is in OverridePolicy.

    Parameter Description Example
    resourceSelectors Resources to override. Match by apiVersion, kind, name, namespace, or labelSelector. Select the web-demo Deployment.
    overrideRules.plaintext Override resource fields with JSONPatch. Set operator, path, and value. Change spec.replicas to 1.
    overrideRules.imageOverrider Override image components: Registry, Repository, or Version. Prepend a registry prefix to the image.
  2. Apply the OverridePolicy:

    kubectl apply -f overridepolicy.yaml

Step 5: View the distribution status

Check whether the application has been distributed to all member clusters:

kubectl amc get deploy -ndemo -M

The output is similar to:

NAME       CLUSTER          READY   UP-TO-DATE   AVAILABLE   AGE    ADOPTION
web-demo   cxxxxxxxxxxxxx   3/3     3            3           3d4h   Y
web-demo   cxxxxxxxxxxxxx   3/3     3            3           3d4h   Y

READY: 3/3 and ADOPTION: Y confirm the application runs in each cluster.

Step 6: Update the application

  1. Update web-demo.yaml to increase replicas to 4:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      namespace: demo
      name: web-demo
    spec:
      replicas: 4
      selector:
        matchLabels:
          app: web-demo
      template:
        metadata:
          labels:
            app: web-demo
        spec:
          containers:
          - name: nginx
            image: registry-cn-hangzhou.ack.aliyuncs.com/acs/web-demo:0.5.0
            ports:
            - containerPort: 80
  2. Apply the updated manifest:

    kubectl apply -f web-demo.yaml
  3. Verify propagation to all clusters:

    kubectl amc get deploy -ndemo -M

    The output is similar to:

    NAME       CLUSTER          READY   UP-TO-DATE   AVAILABLE   AGE    ADOPTION
    web-demo   cxxxxxxxxxxxxx   4/4     4            4           3d4h   Y
    web-demo   cxxxxxxxxxxxxx   4/4     4            4           3d4h   Y

    READY: 4/4 confirms both clusters are updated.

Step 7: Delete application resources

By default, removing an application or PropagationPolicy from the Fleet instance does not delete resources from member clusters.

To delete resources from member clusters:

  1. Set preserveResourcesOnDeletion to false in ClusterPropagationPolicy:

    apiVersion: policy.one.alibabacloud.com/v1alpha1
    kind: ClusterPropagationPolicy
    metadata:
      name: web-demo
    spec:
      preserveResourcesOnDeletion: false
      resourceSelectors:
      - apiVersion: apps/v1
        kind: Deployment
        name: web-demo
      - apiVersion: v1
        kind: Namespace
        name: demo
      placement:
        clusterAffinity:
          clusterNames:
          - ${cluster1-id} # The ID of your cluster.
          - ${cluster2-id} # The ID of your cluster.
        replicaScheduling:
          replicaSchedulingType: Duplicated
  2. Apply the updated policy:

    kubectl apply -f propagationpolicy.yaml
  3. Delete the application resources:

    kubectl delete -f web-demo.yaml
  4. Confirm removal from member clusters:

    kubectl amc get deploy -ndemo -M

    The output is similar to:

    cluster(cxxxxxxxxxxxxx): deployments.apps "web-demo" not found
    cluster(cxxxxxxxxxxxxx): deployments.apps "web-demo" not found

References