Differentiation Policies
Karmada provides independent differentiated policy APIs to configure differentiated configurations related to the clusters. For more information about Karmada, see Karmada.
Creating a Differentiation Policy
- Log in to the MCP console. In the navigation pane, choose Policy Center > Differentiation Policies, and click Create Using YAML.
- Edit the YAML parameters. The following is an example:
apiVersion: policy.karmada.io/v1alpha1 kind: OverridePolicy metadata: name: nginx-ccecluster-deployment namespace: default spec: overriders: plaintext: - operator: replace path: /spec/replicas value: 2 - operator: add path: /spec/template/spec/containers value: - image: 'nginx:perl' imagePullPolicy: IfNotPresent name: container-0 resources: limits: cpu: 250m memory: 512Mi requests: cpu: 250m memory: 512Mi resourceSelectors: - apiVersion: apps/v1 kind: Deployment name: nginx namespace: default targetCluster: clusterNames: - cceclusterTable 1 Differentiation policy parameters Parameter
Type
Description
apiVersion
String
API version. The value is fixed at policy.karmada.io/v1alpha1 and cannot be changed.
kind
String
API type. The value is fixed at OverridePolicy and cannot be changed.
metadata
metadata object
Basic information about the differentiation policy. Metadata is a collection of attributes.
spec
spec object
Detailed properties of the differentiation policy. Objects are created or updated based on the description of spec.
Table 2 metadata Parameter
Type
Description
name
String
Name of the differentiation policy. The name must be unique and contains 1 to 56 characters starting with a letter and not ending with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed.
namespace
String
Namespace to which the differentiation policy belongs.
Table 3 spec Parameter
Type
Description
overriders
overriders object
Content of the differentiation policy.
resourceSelectors
resourceSelectors object
Associated resources. The differentiation policy takes effect for resources that meet the filter criteria.
targetCluster
targetCluster object
Cluster where the differentiation policy takes effect.
Table 4 overriders Parameter
Type
Description
plaintext
Array of plaintext object
Content of the differentiation policy. Multiple policies can be added.
Table 5 plaintext Parameter
Type
Description
operator
String
Differentiation operations performed on the target resource, that is, adding, deleting, or modifying the content in the operation path.
- add: Add a field to the target resource template. The field is specified by the operation path.
- remove: Delete a field from the target resource template. The field is specified by the operation path.
- replace: Update a field in the target resource template. The field is specified by the operation path.
In the following example, the replace operation changes the value of /spec/replicas in the YAML file of the target resource to 2. That is, the number of pods is changed to 2.
- operator: replace path: /spec/replicas value: 2path
String
Operation path, which indicates the location of the differentiated content in the YAML file of the target resource.
For example, if this parameter is set to /spec/replicas, the operation is performed on the /spec/replicas field of the target resource.
value
Type of the target resource parameter
Content to be added, deleted, or modified in the specified operation path.
- If operator is set to add, set this parameter to the content to be added to the target resource path.
- If operator is set to remove, set this parameter to any value. This parameter is meaningless during deletion.
- If operator is set to replace, set this parameter to the new content for replacement in the target resource path.
- Click Create after you finish the editing.
- Click Cluster Console to go to the console of the differentiated cluster to view the differentiation result of the associated resources.
Modifying a Differentiation Policy
- Log in to the MCP console. In the navigation pane, choose Policy Center > Differentiation Policies.
- In the policy list, click View YAML in the Operation column of the differentiation policy to be updated.
- In the displayed dialog box, click Edit to modify the YAML file.

- Click Update after you finish the modification.
- Click Cluster Console to go to the console of the differentiated cluster to view the differentiation result of the associated resources.
Last Article: Propagation Policies
Next Article: Domain Name Access
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.