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:
-
Multi-cluster management is enabled.
-
Multiple clusters are associated with the Fleet instance.
-
kubectl is connected to the Fleet instance using the kubeconfig downloaded from the ACK One console.
-
The
AliyunAdcpFullAccesspolicy is granted to your Resource Access Management (RAM) user. -
The AMC command-line tool is installed.
(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.
-
Create
web-demo.yamlwith 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 -
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.
-
Get the member cluster IDs:
kubectl get mclThe output is similar to:
NAME HUB ACCEPTED MANAGED CLUSTER URLS JOINED AVAILABLE AGE cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx true True True 3d23h cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx true True True 5d21h -
Create
propagationpolicy.yamlwith the following content. Replace${cluster1-id}and${cluster2-id}with your cluster IDs.ClusterPropagationPolicydistributes cluster-scoped resources (such as Namespaces).PropagationPolicydistributes 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: DuplicatedKey parameters are listed below. The full parameter list is in PropagationPolicy.
Parameter Description Example resourceSelectorsResources to distribute. Match by apiVersion,kind,name,namespace, orlabelSelector.Select the web-demoDeployment in thedemonamespace.placement.clusterAffinityTarget clusters for distribution. Enter cluster IDs, not cluster names. ${cluster1-id},${cluster2-id}replicaScheduling.replicaSchedulingTypeScheduling mode. Duplicatedreplicates the full replica count (defined byspec.replicas) to each cluster.Duplicated -
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
replicasfrom3to1 -
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
-
Create
overridepolicy.yamlwith 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 resourceSelectorsResources to override. Match by apiVersion,kind,name,namespace, orlabelSelector.Select the web-demoDeployment.overrideRules.plaintextOverride resource fields with JSONPatch. Set operator,path, andvalue.Change spec.replicasto1.overrideRules.imageOverriderOverride image components: Registry,Repository, orVersion.Prepend a registry prefix to the image. -
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
-
Update
web-demo.yamlto increasereplicasto4: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 -
Apply the updated manifest:
kubectl apply -f web-demo.yaml -
Verify propagation to all clusters:
kubectl amc get deploy -ndemo -MThe 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 YREADY: 4/4confirms 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:
-
Set
preserveResourcesOnDeletiontofalseinClusterPropagationPolicy: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 -
Apply the updated policy:
kubectl apply -f propagationpolicy.yaml -
Delete the application resources:
kubectl delete -f web-demo.yaml -
Confirm removal from member clusters:
kubectl amc get deploy -ndemo -MThe output is similar to:
cluster(cxxxxxxxxxxxxx): deployments.apps "web-demo" not found cluster(cxxxxxxxxxxxxx): deployments.apps "web-demo" not found
References
-
Monitor distributed applications: Monitoring management
-
Implement zone-disaster recovery: Use MSE multi-cluster gateways to implement zone-disaster recovery in ACK One
-
Full parameter reference: PropagationPolicy and OverridePolicy