4.2.2. 节点选择器
您可以在特定节点集合上运行 metering 组件。在 metering 组件上设置 nodeSelector
来控制组件的调度位置。以下 node-selectors.yaml
文件提供了一个针对各个组件设置节点选择器的示例。
为 operand Pod 配置特定节点选择器前,将 openshift.io/node-selector: ""
命名空间注解添加到 metering 命名空间 YAML 文件。将 ""
指定为注解值。
apiVersion: metering.openshift.io/v1 kind: MeteringConfig metadata: name: "operator-metering" spec: reporting-operator: spec: nodeSelector: "node-role.kubernetes.io/infra": "" 1 presto: spec: coordinator: nodeSelector: "node-role.kubernetes.io/infra": "" 2 worker: nodeSelector: "node-role.kubernetes.io/infra": "" 3 hive: spec: metastore: nodeSelector: "node-role.kubernetes.io/infra": "" 4 server: nodeSelector: "node-role.kubernetes.io/infra": "" 5
为 operand Pod 配置特定节点选择器前,将 openshift.io/node-selector: ""
命名空间注解添加到 metering 命名空间 YAML 文件。在项目上设置 openshift.io/node-selector
注解时,该值优先于集群范围的 Scheduler
对象中的 spec.defaultNodeSelector
字段的值。
验证
您可以通过执行以下任一检查来验证 metering 节点选择器:
验证
MeteringConfig
自定义资源中配置的节点的 IP 地址是否正确调度了 metering 的所有 pod:检查
openshift-metering
命名空间中的所有 pod:$ oc --namespace openshift-metering get pods -o wide
输出显示了在
openshift-metering
命名空间中运行的每个 Pod 的NODE
和对应IP
。输出示例
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES hive-metastore-0 1/2 Running 0 4m33s 10.129.2.26 ip-10-0-210-167.us-east-2.compute.internal <none> <none> hive-server-0 2/3 Running 0 4m21s 10.128.2.26 ip-10-0-150-175.us-east-2.compute.internal <none> <none> metering-operator-964b4fb55-4p699 2/2 Running 0 7h30m 10.131.0.33 ip-10-0-189-6.us-east-2.compute.internal <none> <none> nfs-server 1/1 Running 0 7h30m 10.129.2.24 ip-10-0-210-167.us-east-2.compute.internal <none> <none> presto-coordinator-0 2/2 Running 0 4m8s 10.131.0.35 ip-10-0-189-6.us-east-2.compute.internal <none> <none> reporting-operator-869b854c78-8g2x5 1/2 Running 0 7h27m 10.128.2.25 ip-10-0-150-175.us-east-2.compute.internal <none> <none>
将
openshift-metering
命名空间中的节点与集群中的每个节点NAME
进行比较:$ oc get nodes
输出示例
NAME STATUS ROLES AGE VERSION ip-10-0-147-106.us-east-2.compute.internal Ready master 14h v1.19.0+6025c28 ip-10-0-150-175.us-east-2.compute.internal Ready worker 14h v1.19.0+6025c28 ip-10-0-175-23.us-east-2.compute.internal Ready master 14h v1.19.0+6025c28 ip-10-0-189-6.us-east-2.compute.internal Ready worker 14h v1.19.0+6025c28 ip-10-0-205-158.us-east-2.compute.internal Ready master 14h v1.19.0+6025c28 ip-10-0-210-167.us-east-2.compute.internal Ready worker 14h v1.19.0+6025c28
验证
MeteringConfig
自定义资源中节点选择器配置不会影响集群范围节点选择器配置,因此没有调度 metering operand Pod。检查集群范围的
Scheduler
对象spec.defaultNodeSelector
字段,这显示调度 pod 的默认位置:$ oc get schedulers.config.openshift.io cluster -o yaml