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.3.3. 配置 pod 反关联性规则
以下步骤演示了一个简单的双 pod 配置,它创建一个带有某标签的 pod,以及一个使用反关联性偏好规则来尝试阻止随着该 pod 一起调度的 pod。
流程
创建在
Podspec 中带有特定标签的 pod:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
在创建其他 pod 时,编辑
Podspec 来设置以下参数: 使用
podAntiAffinity小节配置requiredDuringSchedulingIgnoredDuringExecution参数或preferredDuringSchedulingIgnoredDuringExecution参数:- 为节点指定一个 1 到 100 的权重。优先选择权重最高的节点。
指定必须满足的键和值。如果您希望新 pod 不与另一个 pod 一起调度,请使用与第一个 pod 上标签相同的
key和value参数。Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 为偏好规则指定一个 1 到 100 的权重。
-
指定一个
operator。运算符可以是In、NotIn、Exists或DoesNotExist。例如,使用运算符In来要求节点上存在该标签。
-
指定
topologyKey,这是一个预填充的 Kubernetes 标签,供系统用于表示这样的拓扑域。 创建 pod。
oc create -f <pod-spec>.yaml
$ oc create -f <pod-spec>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow