Updated on 2024-09-24 GMT+08:00

Node Affinity

  1. Log in to the CCE Console console and click the cluster name to access the cluster console. In the navigation pane, choose Nodes > Nodes. Then, locate the node and choose More > Edit YAML in the Operation column.
  2. Configure the following parameters in YAML:

    metadata:
      labels:
        istio: ingressgateway

    You can also choose More > Manage Label in the Operation column of the node to configure the parameters.

  3. 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.
  4. Configure the following parameters in YAML:

    spec:
      template: 
    spec:
          affinity:
            nodeAffinity:
              requiredDuringSchedulingIgnoredDuringExecution:
                nodeSelectorTerms:
                  - matchExpressions:
                      - key: istio
                        operator: In
                        values:
                          - ingressgateway

    You can also click Upgrade in the Operation column of the workload to configure the parameters.

    Recommended value description:

    Required: Pods are scheduled to the node with the istio:ingressgateway label.

    Node affinity parameters

    Parameter

    Description

    Required

    Hard constraint, which corresponds to requiredDuringSchedulingIgnoredDuringExecution for specifying the conditions that must be met.

    If multiple rules that must be met are added, scheduling will be performed when only one rule is met.

    Preferred

    Soft constraint, which corresponds to preferredDuringSchedulingIgnoredDuringExecution for specifying the conditions that need to be met as much as possible.

    If multiple rules that are preferentially met are added, scheduling will be performed even if one or none of the rules is met.

    Parameters for configuring node affinity scheduling policies

    Parameter

    Description

    Label Key

    When configuring node affinity, enter the node 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.
    • Gt: (available only for node affinity) The label value of the scheduled node is greater than the list value (string comparison).
    • Lt: (available only for node affinity) The label value of the scheduled node is less than the list value (string comparison).

    Label Value

    When configuring node affinity, enter the value of the node label.

Configuring node affinity parameters will trigger a workload rolling upgrade. This means pods will restart immediately.