This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.3.5.3. 配置首选的节点关联性规则
偏好规则指定在满足规则时调度程序会尝试强制执行规则,但不保证一定能强制执行成功。
流程
以下步骤演示了一个简单的配置,此配置会创建一个节点,以及调度程序尝试放置到该节点上的 pod。
使用
oc label node
命令给节点添加标签:oc label node node1 e2e-az-name=e2e-az3
$ oc label node node1 e2e-az-name=e2e-az3
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在
Pod
spec 中,使用nodeAffinity
小节来配置preferredDuringSchedulingIgnoredDuringExecution
参数:- 为节点指定一个权重,值为 1 到 100 的数字。优先选择权重最高的节点。
指定必须满足的键和值。如果希望新 pod 调度到您编辑的节点上,请使用与节点中标签相同的
key
和value
参数:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
指定一个
operator
。运算符可以是In
、NotIn
、Exists
或DoesNotExist
、Lt
或Gt
。例如,使用运算符In
来要求节点上存在该标签:
创建 pod。
oc create -f e2e-az3.yaml
$ oc create -f e2e-az3.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow