Menu Close

4.2. 通用配置选项

4.2.1. 资源请求和限值

您可针对 Pod 和卷调整 CPU、内存或存储资源请求和/或限值。以下 default-resource-limits.yaml 提供了一个针对各个组件设置资源请求和限值的示例。

apiVersion: metering.openshift.io/v1
kind: MeteringConfig
metadata:
  name: "operator-metering"
spec:
  reporting-operator:
    spec:
      resources:
        limits:
          cpu: 1
          memory: 500Mi
        requests:
          cpu: 500m
          memory: 100Mi
  presto:
    spec:
      coordinator:
        resources:
          limits:
            cpu: 4
            memory: 4Gi
          requests:
            cpu: 2
            memory: 2Gi

      worker:
        replicas: 0
        resources:
          limits:
            cpu: 8
            memory: 8Gi
          requests:
            cpu: 4
            memory: 2Gi

  hive:
    spec:
      metastore:
        resources:
          limits:
            cpu: 4
            memory: 2Gi
          requests:
            cpu: 500m
            memory: 650Mi
        storage:
          class: null
          create: true
          size: 5Gi
      server:
        resources:
          limits:
            cpu: 1
            memory: 1Gi
          requests:
            cpu: 500m
            memory: 500Mi

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
1 2 3 4 5
添加 nodeSelector 参数,并设为适用于您想要移动的组件的值。您可以根据为节点指定的值,按所示格式使用 nodeSelector 或使用键-值对。
注意

为 operand Pod 配置特定节点选择器前,将 openshift.io/node-selector: "" 命名空间注解添加到 metering 命名空间 YAML 文件。在项目上设置 openshift.io/node-selector 注解时,该值优先于集群范围的调度程序对象中的 spec.defaultNodeSelector 字段的值。

验证

您可以通过执行以下任一检查来验证 metering 节点选择器:

  • 验证 MeteringConfig 自定义资源中配置的节点的 IP 地址是否正确调度了 metering 的所有 Pod:

    流程

    1. 检查 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>
    2. 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.18.3+6025c28
      ip-10-0-150-175.us-east-2.compute.internal   Ready    worker   14h   v1.18.3+6025c28
      ip-10-0-175-23.us-east-2.compute.internal    Ready    master   14h   v1.18.3+6025c28
      ip-10-0-189-6.us-east-2.compute.internal     Ready    worker   14h   v1.18.3+6025c28
      ip-10-0-205-158.us-east-2.compute.internal   Ready    master   14h   v1.18.3+6025c28
      ip-10-0-210-167.us-east-2.compute.internal   Ready    worker   14h   v1.18.3+6025c28
  • 验证 MeteringConfig 自定义资源中节点选择器配置不会影响集群范围节点选择器配置,因此没有调度 metering operand Pod。

    流程

    • 使用 spec.defaultNodeSelector 字段检查集群范围的调度程序对象,该字段显示调度 Pod 的默认位置:

      $ oc get schedulers.config.openshift.io cluster -o yaml