搜索

第 14 章 工作负载分区

download PDF

在资源受限环境中,您可以使用工作负载分区来隔离 OpenShift Container Platform 服务、集群管理工作负载和基础架构 pod,以便在保留的一组 CPU 上运行。

集群管理所需的最小保留 CPU 数量是 4 个 CPU Hyper-Threads (HT)。使用工作负载分区,您可以注解一组集群管理 pod 和一组典型的附加 Operator,以包含在集群管理工作负载分区中。这些 pod 通常在大小为最小要求的 CPU 配置中运行。除了最小集群管理 pod 之外,额外的其他 Operator 或工作负载则需要将额外的 CPU 添加到工作负载分区中。

工作负载分区使用标准 Kubernetes 调度功能将用户工作负载与平台工作负载隔离。

工作负载分区需要以下更改:

  1. install-config.yaml 文件中,添加额外的字段:cpuPartitioningMode

    apiVersion: v1
    baseDomain: devcluster.openshift.com
    cpuPartitioningMode: AllNodes 1
    compute:
      - architecture: amd64
        hyperthreading: Enabled
        name: worker
        platform: {}
        replicas: 3
    controlPlane:
      architecture: amd64
      hyperthreading: Enabled
      name: master
      platform: {}
      replicas: 3
    1
    在安装时为 CPU 分区设置集群。默认值为 None
    注意

    工作负载分区只能在集群安装过程中启用。您不能在安装后禁用工作负载分区。

  2. 在性能配置集中,指定 isolatedreserved CPU。

    推荐的性能配置集配置

    apiVersion: performance.openshift.io/v2
    kind: PerformanceProfile
    metadata:
      # if you change this name make sure the 'include' line in TunedPerformancePatch.yaml
      # matches this name: include=openshift-node-performance-${PerformanceProfile.metadata.name}
      # Also in file 'validatorCRs/informDuValidator.yaml':
      # name: 50-performance-${PerformanceProfile.metadata.name}
      name: openshift-node-performance-profile
      annotations:
        ran.openshift.io/reference-configuration: "ran-du.redhat.com"
    spec:
      additionalKernelArgs:
        - "rcupdate.rcu_normal_after_boot=0"
        - "efi=runtime"
        - "vfio_pci.enable_sriov=1"
        - "vfio_pci.disable_idle_d3=1"
        - "module_blacklist=irdma"
      cpu:
        isolated: $isolated
        reserved: $reserved
      hugepages:
        defaultHugepagesSize: $defaultHugepagesSize
        pages:
          - size: $size
            count: $count
            node: $node
      machineConfigPoolSelector:
        pools.operator.machineconfiguration.openshift.io/$mcp: ""
      nodeSelector:
        node-role.kubernetes.io/$mcp: ''
      numa:
        topologyPolicy: "restricted"
      # To use the standard (non-realtime) kernel, set enabled to false
      realTimeKernel:
        enabled: true
      workloadHints:
        # WorkloadHints defines the set of upper level flags for different type of workloads.
        # See https://github.com/openshift/cluster-node-tuning-operator/blob/master/docs/performanceprofile/performance_profile.md#workloadhints
        # for detailed descriptions of each item.
        # The configuration below is set for a low latency, performance mode.
        realTime: true
        highPowerConsumption: false
        perPodPowerManagement: false

    表 14.1. 单节点 OpenShift 集群的 PerformanceProfile CR 选项
    PerformanceProfile CR 字段描述

    metadata.name

    确保名称与相关 GitOps ZTP 自定义资源(CR)中设置的以下字段匹配:

    • TunedPerformancePatch.yaml 中的 include=openshift-node-performance-${PerformanceProfile.metadata.name}
    • validatorCRs/informDuValidator.yaml 中的 name: 50-performance-${PerformanceProfile.metadata.name}

    spec.additionalKernelArgs

    "efi=runtime" 为集群主机配置 UEFI 安全引导。

    spec.cpu.isolated

    设置隔离的 CPU。确保所有 Hyper-Threading 对都匹配。

    重要

    保留和隔离的 CPU 池不得重叠,并且必须一起跨越所有可用的内核。未考虑导致系统中未定义的 CPU 内核。

    spec.cpu.reserved

    设置保留的 CPU。启用工作负载分区时,系统进程、内核线程和系统容器线程仅限于这些 CPU。所有不是隔离的 CPU 都应保留。

    spec.hugepages.pages

    • 设置巨页数量(数量)
    • 设置巨页大小(大小)。
    • node 设置为 NUMA 节点,它是 hugepages 分配的位置 (node)

    spec.realTimeKernel

    enabled 设置为 true 以使用实时内核。

    spec.workloadHints

    使用 workloadHints 为不同类型的工作负载定义顶级标记集合。示例配置为低延迟和高性能配置集群。

工作负载分区为平台 pod 引进了扩展 management.workload.openshift.io/cores 资源类型。kubelet 公告分配给对应资源内池的 pod 的资源和 CPU 请求。启用工作负载分区后,management.workload.openshift.io/cores 资源允许调度程序根据主机的 cpushares 容量正确分配 pod,而不只是默认的 cpuset

其他资源

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.