Load Affinity
- Log in to the CCE Console console and click the cluster name to access the cluster console. In the navigation pane, choose Workloads. Then, locate the workload you want to upgrade and choose More > Edit YAML in the Operation column.
- Configure the following parameters in YAML:
spec: template: spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: app operator: In values: - istio-ingressgateway namespaces: - istio-system topologyKey: kubernetes.io/hostname preferredDuringSchedulingIgnoredDuringExecution: - weight: 1 podAffinityTerm: labelSelector: matchExpressions: - key: app operator: In values: - istio-ingressgateway namespaces: - istio-system topologyKey: topology.kubernetes.io/zone
You can also click Upgrade in the Operation column of the workload to configure the parameters.
Recommended value description:
- Required: Pods are scheduled to different nodes.
- Preferred: Pods are preferentially scheduled to nodes in different AZs.
Load affinity policies
Policy
Trigger Type
Description
Workload Affinity
Required
Hard constraint, which corresponds to requiredDuringSchedulingIgnoredDuringExecution in YAML for specifying the conditions that must be met.
Select pods that require affinity by label. If such pods already run on a node in the topology key, the scheduler will forcibly schedule the created pods to that topology key.
Note:
If multiple affinity rules are configured, multiple labels will be used to filter pods that require affinity, and the newly created pods must have affinity with all pods that meet the label filtering conditions. In this way, all pods that meet the label filtering conditions locate in the same topology key for scheduling.
Preferred
Soft constraint, which corresponds to preferredDuringSchedulingIgnoredDuringExecution in YAML for specifying the conditions that need to be met as much as possible.
Select pods that require affinity by label. If such pods already run on a node in the topology key, the scheduler will preferentially schedule the created pods to that topology key.
Note:
If multiple affinity rules are configured, multiple labels will be used to filter pods that require affinity, and the newly created pods will be preferentially to have affinity with multiple pods that meet the label filtering conditions. However, even if no pod meets the label filtering conditions, a topology key will be selected for scheduling.
Workload Anti-Affinity
Required
Hard constraint, which corresponds to requiredDuringSchedulingIgnoredDuringExecution in YAML for specifying the conditions that must be met.
Select one or more pods that require anti-affinity by label. If such pods already run on a node in the topology key, the scheduler will not schedule the created pods to that topology key.
Note:
If multiple anti-affinity rules are configured, multiple labels will be used to filter pods that require anti-affinity, and the newly created pods must have anti-affinity with all pods that meet the label filtering conditions. In this way, all the topology keys where the pods that meet the label filtering conditions locate will not be scheduled.
Preferred
Soft constraint, which corresponds to preferredDuringSchedulingIgnoredDuringExecution in YAML for specifying the conditions that need to be met as much as possible.
Select one or more pods that require anti-affinity by label. If such pods already run on a node in the topology key, the scheduler will preferentially schedule the created pods to other topology keys.
Note:
If multiple anti-affinity rules are configured, multiple labels will be used to filter pods that require anti-affinity, and the newly created pods will be preferentially to have anti-affinity with multiple pods that meet the label filtering conditions. However, even if all topology keys involve the pods that require anti-affinity, a topology key will be selected for scheduling.
Parameters for configuring workload affinity/anti-affinity scheduling policies
Parameter
Description
Weight
This parameter is only available in a preferred scheduling policy. The weight ranges from 1 to 100. During scheduling, the scheduler adds the weight to the scores of other priority functions and schedules pods to the node with the largest total score.
Namespace
Namespace for which the scheduling policy takes effect.
Topology Key
A topology key (topologyKey) determines the range of nodes to be scheduled based on node labels. For example, if the node label is kubernetes.io/hostname, the range of nodes is determined by node name. Nodes with different names are in different topology keys. In this case, a topology key contains only one node. If the specified label is kubernetes.io/os, the range of nodes is determined by node OS. Nodes running different OSs belong to different topology keys. In this case, a topology key may contain multiple nodes.
After the node range is determined using the topology key, configure the policy for scheduling, including the label key, operator, and label value. The minimum unit for scheduling is a topology key. For example, if a node in a topology key meets the load affinity policy, all nodes in the topology key can be scheduled.
Label Key
When configuring a workload affinity or anti-affinity policy, enter the workload label to be matched.
Both default labels and custom labels are supported.
Operator
The following operators are supported:
- In: The label of the affinity or anti-affinity object is in the label value list (values field).
- NotIn: The label of the affinity or anti-affinity object is not in the label value list (values field).
- Exists: The affinity or anti-affinity object has a specified label key.
- DoesNotExist: The affinity or anti-affinity object does not have a specified label key.
Label Value
When configuring a workload affinity or anti-affinity policy, enter the value of the workload label.
Configuring load affinity parameters will trigger a workload rolling upgrade. This means pods will restart immediately.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot