Skip to content

Differentiation strategy

The role of the differentiation policy (Override Policy) is to define the configurations delivered to different clusters, which can be different. For example, the addresses of the mirror warehouses corresponding to different clusters are different, so they need to be set in different clusters. The mirroring addresses of the workloads in the server are different. For example, in different environments, different environment variables need to be set. The timing of the differentiation policy (Override Policy) is after the deployment policy (Propagation Policy) and before it is actually delivered to the cluster.

Multicloud Management supports differentiated strategies, supports viewing the list of differentiated strategies of the current instance and its associated multicloud resources on the interface, and can create and update the information of differentiated strategies through forms and YAML. Differentiation policy (Override Policy) is divided into namespace level and cluster level.

YAML creation

Follow the steps below to create a differentiation strategy using YAML.

  1. After entering a multicloud instance, in the left navigation bar, click Policy Management -> Differential Policy, and click the YAML Create button.

  2. On the YAML Creation page, after entering the correct YAML statement, click OK.

  3. Return to the deployment policy list, and the newly created one is the first one by default. Click on the right side of the list to edit YAML and perform delete operations.

    !!! note

     If you want to delete a deployment policy, you need to remove the workload related to the policy first. After the deletion, all the information related to the policy will be deleted. Please operate with caution.
    

YAML example

Here is an example YAML for a diff policy that you can use with a little modification.

kind: OverridePolicy
apiVersion: policy.karmada.io/v1alpha1
metadata:
   name: nginx-op
   namespace: default
   uid: 09f89bc4-c6bf-47b3-81bf-9e494b831aac
   resourceVersion: '856977'
   generation: 1
   creationTimestamp: '2022-09-21T10:30:40Z'
   labels:
     a:b
   annotations:
     shadow.clusterpedia.io/cluster-name:k-kairshiptest
spec:
   resourceSelectors:
     - apiVersion: apps/v1
       kind: Deployment
       namespace: default
       name: nginx
   overriders: {}

Form Creation

Follow the steps below to create a differentiation strategy.

  1. Go to the namespace-level menu and click the Create Differentiation Policy button.

  2. Enter the form creation page. To create a complete differentiated strategy, you need to configure three parts: basic configuration, resource configuration, and differentiated strategy.

    • Basic configuration: including name, multicloud namespace, tags and annotations. Where Name and Multicloud Namespace are required.

    • Resource configuration: Supports the selection of multicloud resources under the selected multicloud namespace for differentiated configuration, and multicloud resources also support multiple selections.

    • Differentiation strategy: support for adding mirroring/running parameters/running commands/customization and other differentiated configurations.

  3. After completing the filling, click OK to create successfully. It supports YAML update, form update, and delete operations for a differentiated strategy.

Detailed differentiation strategy

Next, we will introduce the differentiation strategies in detail, which are divided into six types and support adding multiple differentiation configurations:

  1. Select ImageOverrider: Differential configuration of mirroring.

    1. Select a deployment cluster

      Support ClusterNames (cluster name), FieldSelector (area), and LabelSelector (label) to select the deployment cluster.

      === ClusterNames: directly select the specified cluster name

      === FieldSelector: Select clusters by fields, including:

      • provider (a service provider that provides cluster infrastructure)
      • region (area: a collection of availability zones, referring to a specific geographic location where resources can be hosted, such as Beijing, Shanghai, Shenzhen, Chengdu, etc.)
      • zone (Availability zone: is the deployment area within the region, such as Shanghai Availability Zone 1, Shanghai Availability Zone 2·······)
      • Also supports excluding a specified cluster from the selected clusters.

      === LabelSelector: Select clusters by labels, support custom labels, and also support exclusion of specified clusters.

    2. Differentiated configuration for mirroring the selected clusters

      Field Required Description Example
      Component is Image component Registry, Repository, Tag
      Operator is the operation on the image add, remove, replace
      Value No When the Operator is add or replace, it cannot be empty, and it is empty by default; when the operator is remove, leave it blank.
  2. When ArgsOverrider is selected: Differential configuration of running parameters.

    1. Select a deployment cluster

    2. Differentiated configuration of operating parameters for the selected clusters

      Field Required Description Example
      ContainerName is container name
      Operator is the operation to apply on args add, remove
      Value No The value to apply to args. When the operator is add, the value is appended to args; when the operator is remove, the value is removed from args; if the value is empty, args remains as it is.
  3. When CommandOverrider is selected: Run the differential configuration of the command.

    1. Select a deployment cluster

    2. Perform differential configuration of running commands on selected clusters

      Field Required Description Example
      ContainerName is container name
      Operator is the operation applied to the command add, remove
      Value No The value applied to the command. When the operator is add, the value is appended to the command; when the operator is remove, the value is removed from the command; if the value is empty, the command remains as it is. You can add single or multiple values, use ; to divide multiple values
  4. When PlainText is selected: Custom differentiated configuration.

    1. Select a deployment cluster

    2. Perform differential configuration of running commands on selected clusters

      Field Required Description Example
      Path is the path to the target field
      Operator is the type of operation on the target field add, remove, replace
  5. When LabelsOverrider is selected: Label differentiation configuration.

    1. Select a deployment cluster

    2. Perform differential configuration of running tags for the selected clusters

      Field Required Description Example
      Key is the key of the label
      Operator is the type of operation on the target field add, remove, replace
      Value No The value of the tag
  6. When selecting AnnotationsOverrider: differentiated configuration of annotations.

    1. Select a deployment cluster

    2. Differentiated configuration of running annotations for selected clusters

      Field Required Description Example
      Key is the key of the annotation
      Operator is the type of operation on the target field add, remove, replace
      Value No The value of the annotation

Comments