1.2. 自定义 Service Operator 容限
容限根据匹配的污点控制调度程序用于 pod 放置的节点或节点组。您可以覆盖默认容限,并为每个服务添加额外的容限,以控制调度程序放置服务 pod 的位置。
先决条件
-
已使用污点配置了
Node自定义资源(CR)。
流程
查看默认服务 Operator 容限:
$ oc get deployment <service>-operator-controller-manager -o yaml | yq .spec.template.spec.tolerations - effect: NoExecute key: node.kubernetes.io/not-ready operator: Exists tolerationSeconds: 120 - effect: NoExecute key: node.kubernetes.io/unreachable operator: Exists tolerationSeconds: 120 - effect: NoSchedule key: node.example.com/infra operator: Equal value: infra-
将
<service> 替换为您要查看容限的服务的名称,如infra或keystone。
如需有关容限字段的信息,请参阅了解污点和容限。
-
将
在工作站上创建名为
openstack_operator_overrides.yaml的文件,或者打开该文件(如果已存在):apiVersion: operator.openstack.org/v1beta1 kind: OpenStack metadata: name: openstack namespace: openstack-operators根据您的环境需要覆盖容限配置或添加新容限:
spec: operatorOverrides: - name: <service> tolerations: - effect: NoSchedule key: node.example.com/infra operator: Equal value: infra tolerationSeconds: 600 - name: <service> tolerations: ...tolerations.effect: 指定在容限字符串与污点字符串不匹配时要与 pod 执行的操作。设置为以下有效值之一:-
NoSchedule:与污点不匹配的新 pod 不会调度到该节点上。 -
PreferNoSchedule: 与污点不匹配的新 pod 可能会调度到该节点上,但调度程序不会将这些 pod 调度到该节点上。 -
NoExecute: 与污点不匹配的新 pod 无法调度到该节点上。
-
-
tolerations.key:代表污点的任何字符串,最多 253 个字符。有关任何 RHOCP 集群中可用的默认污点列表,请参阅了解污点和容限。 tolerations.operator: 指定在将 pod 调度到节点时是否使用值字符串。设置为以下有效值之一:-
等于:键/值/effect 参数必须匹配。这是默认值。 -
存在 : key/effect 参数必须匹配。
您必须保留一个空 value 参数,该参数与任何参数匹配。
-
-
tolerations.value: 任何字符串,最多 63 个字符,必须与为污点设置的值匹配。当 Operator 被设置为时,不要设置。Exists -
tolerations.tolerationSeconds:一个可选字段,指定 pod 在被驱除前可以保持与节点绑定的时长,以秒为单位。
更新 OpenStack Operator:
$ oc apply -f openstack_operator_overrides.yaml -n openstack-operators确认应用了更新的容限:
$ oc get deployment <service>-operator-controller-manager -o yaml | yq .spec.template.spec.tolerations - effect: NoExecute key: node.kubernetes.io/not-ready operator: Exists tolerationSeconds: 120 - effect: NoExecute key: node.kubernetes.io/unreachable operator: Exists tolerationSeconds: 120 - effect: NoSchedule key: node.example.com/infra operator: Equal value: infra