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: web-demo
namespace: demo
spec:
resourceSelectors:
- apiVersion: apps/v1
kind: Deployment
name: web-demo
- apiVersion: v1
kind: ConfigMap
name: cm-demo
- apiVersion: apps/v1
kind: Deployment
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- xxxx
preserveResourcesOnDeletion: true
placement:
clusterAffinity:
clusterNames:
- cxxxxx # The ID of your cluster.
- cxxxxx # The ID of your cluster.
replicaScheduling:
replicaSchedulingType: Divided
replicaDivisionPreference: Weighted
weightPreference:
staticWeightList:
- targetCluster:
clusterNames:
- cxxxxx
weight: 2
- targetCluster:
clusterNames:
- cxxxxxx
weight: 1Parameters
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. | |
propagateDeps | No | Specify whether referenced resources are automatically propagated to associated clusters. For example, when a Deployment references a ConfigMap, this parameter determines if the ConfigMap is synchronized to the associated clusters. | true |
placement | Yes |
| |
dependentOverrides | No | The Indicate that resource propagation will wait until all dependent | |
failover | No | The
| |
preserveResourcesOnDeletion | Yes | Specify whether resources propagated by the policy are retained when the policy is deleted. Default value: | false |
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 |
clusterNames | 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 |
customSchedulingType | No | The custom scheduling strategy. Only Gang scheduling is supported for workloads. | Gang |
replicaDivisionPreference | No | Specify how pods are divided across clusters:
| weighted |
weightPreference | No | Specify whether to use dynamic or static weighting for pod propagation:
|
|
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:
clusterNames:
-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/xxxxParameters
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 |
clusterNames | 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.