Distributed Cloud Container Platform for Kubernetes (ACK One) Fleet instances propagate applications based on the PropagationPolicy and OverridePolicy. The PropagationPolicy is used to define which resources need to be propagated to which clusters. The OverridePolicy is used to define which configurations to be overridden when resources are propagated to different clusters. This topic describes how to configure the PropagationPolicy and OverridePolicy.
PropagationPolicy
You can define the PropagationPolicy
and ClusterPropagationPolicy
to propagate multi-cluster applications. The PropagationPolicy
and ClusterPropagationPolicy
are designed based on the open source project Karmada and are compatible with the ClusterPropagationPolicy
and PropagationPolicy
APIs of Karmada.
ClusterPropagationPolicy
: This policy allows you to propagate cluster-wide resources, includingPersistentVolume
,StorageClass
,Namespace
, andCustomResourceDefinition
. This policy also allows you to propagate resources in any namespace other than the system reserved namespaces. For more information about the role-based access control (RBAC) permissions required for propagating resources, see RBAC permissions on Fleet instances.PropagationPolicy
: This policy allows you to propagate namespace-wide resources. Only resources in the namespace specified by the policy are propagated.
In the following section, the PropagationPolicy
that propagates applications based on static weights is used as an example to describe how to configure a propagation policy.
apiVersion: one.alibabacloud.com/v1alpha1
kind: PropagationPolicy
metadata:
name: example
namespace: demo
spec:
resourceSelectors:
- apiVersion: apps/v1
kind: Deployment
name: demo-deploy
- apiVersion: v1
kind: ConfigMap
name: demo-cm
- apiVersion: apps/v1
kind: Deployment
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- xxxx
prune: false
conflictResolution: abort
placement:
clusterAffinity:
clusterIds:
-cxxxxx # The ID of your cluster.
-cxxxxx # The ID of your cluster.
replicaScheduling:
replicaSchedulingType: Divided
replicaDivisionPreference: Weighted
weightPreference:
staticWeightList:
- targetCluster:
clusterIds:
- cxxxxx
weight: 2
- targetCluster:
clusterIds:
- cxxxxxx
weight: 1
Parameters
Parameter | Required | Description | Example |
apiVersion | Yes | The API version information. | The value is fixed to |
kind | Yes | The type of the policy. Valid values:
| PropagationPolicy |
namespace | No | If you set the | demo |
name | No | The name of the propagation policy. | policy-xxxx |
resourceSelectors | No | Select one or more Kubernetes resources that you want to propagate. For more information, see resourceSelector. |
|
placement | Yes |
|
|
prune | Yes | Specifies whether to delete the resources after the | false |
conflictResolution | Yes | The policy used to handle resource propagation conflicts. Valid values:
| Abort |
resourceSelector
Parameter | Required | Description | Example |
apiVersion | Yes | The version of the resource propagation API. | v1 |
kind | Yes | The type of resource to propagate. | Deployment |
namespace | No | The namespace of the propagated resource. Note If you use the | demo |
name | No | The name of the propagated resource. | Any name |
labelSelector | No | Select the resources to be propagated by using a label selector.
|
|
clusterAffinity
Parameter | Required | Description | Example |
clusterIds | No | The IDs of the clusters to which you want to propagate resources. |
|
excludeClusters | No | The IDs of the clusters that you want to exclude. |
|
labelSelector | No | Select clusters by using a label selector. |
|
replicaScheduling
Parameter | Required | Description | Example |
replicaSchedulingType | No | The pod scheduling policy. Valid values:
| Duplicated |
replicaDivisionPreference | No | The policy for dividing pods. If you set the value to weighted, pods are scheduled based on weights. | weighted |
weightPreference | No |
| The following example shows that the weight of cluster1 is 2 and the weight of cluster2 is 1. If the total number of pods is three, two pods are scheduled to cluster1 and one pod is scheduled to cluster2.
|
OverridePolicy
During application propagation, some clusters may require different configurations. The OverridePolicy can be used to override resources that are propagated to different clusters. You can define the ClusterOverridePolicy
and OverridePolicy
. The ClusterOverridePolicy
and OverridePolicy
are designed based on the open source project Karmada and are compatible with the ClusterOverridePolicy
and OverridePolicy
APIs of Karmada.
ClusterOverridePolicy
: This policy allows you to override cluster-side resources, includingPersistentVolume
,StorageClass
,Namespace
, andCustomResourceDefinition
. You can also override resources in any namespace other than the system reserved namespaces.OverridePolicy
: This policy allows you to override namespace-wide resources. You can override only resources in the namespace specified by the policy.
In the following section, the OverridePolicy
is used as an example to describe how to configure an override policy.
apiVersion: one.alibabacloud.com/v1alpha1
kind: OverridePolicy
metadata:
name: demo
namespace: demo
spec:
resourceSelectors:
- apiVersion: apps/v1
kind: Deployment
name: example
overrideRules:
- targetCluster:
clusterIds:
-cxxxxx # The ID of your cluster.
overriders:
plaintext:
- operator: replace
path: /spec/replicas
value: 1
imageOverrider:
- component: Registry
operator: add
value: registry.cn-hangzhou.aliyuncs.com/xxxx
Parameters
Parameter | Required | Description | Example |
apiVersion | Yes | The API version information. | The value is fixed to |
kind | Yes | The type of the override policy. Valid values:
| OverridePolicy |
namespace | No | If you set the | demo |
name | Yes | The name of the override policy. | Any name |
resourceSelectors | Yes | The resourceSelector array. For more information, see resourceSelector. |
|
overrideRules | Yes | The ruleWithCluster array. For more information, see ruleWithCluster. |
|
resourceSelector
Parameter | Required | Description | Example |
apiVersion | Yes | Set to the | v1 |
kind | Yes | The type of resource to propagate. | Deployment |
namespace | No | The namespace of the propagated resource. Note If you use the | demo |
name | No | The name of the propagated resource. | Any name |
labelSelector | No | Select the resources that you want to propagate by using a label selector. |
|
clusterAffinity
Parameter | Required | Description | Example |
clusterIds | No | The IDs of the clusters to which you want to propagate resources. |
|
excludeClusters | No | The IDs of the clusters that you want to exclude. |
|
labelSelector | No | Select clusters by using a label selector. |
|
ruleWithCluster
Parameter | Required | Description | Example |
targetCluster | Yes | Select clusters based on the | |
overriders | Yes | The
|
|
overriders
Parameter | Required | Description | Example |
imageOverrider | No | The method used to override images.
|
|
plaintext | No | Override resources by using JSONPatch.
|
|
References
For more information about how to create an application on a Fleet instance and how to propagate the application to multiple clusters by configuring the PropagationPolicy or OverridePolicy, see Get started with application distribution.