第 19 章 创建性能配置集
了解 Performance Profile Creator(PPC),以及如何使用它来创建性能配置集。
19.1. 关于性能配置集创建器 复制链接链接已复制到粘贴板!
Performance Profile Creator(PPC)是一个命令行工具,附带 Performance Addon Operator,用于创建性能配置集。该工具消耗来自集群的 must-gather 数据以及几个用户提供的配置集参数。PPC 生成适合您的硬件和拓扑的性能配置集。
该工具使用以下方法之一运行:
-
调用
podman - 调用一个打包程序脚本
19.1.1. 使用 must-gather 命令收集有关集群的数据 复制链接链接已复制到粘贴板!
Performance Profile Creator(PPC)工具需要 must-gather 数据。作为集群管理员,运行 must-gather 命令来捕获集群的信息。
先决条件
-
使用具有
cluster-admin角色的用户访问集群。 - 访问 Performance Addon Operator 镜像。
-
已安装 OpenShift CLI(
oc)。
流程
-
进入存储
must-gather数据的目录。 在集群中运行
must-gather:$ oc adm must-gather --image=<PAO_image> --dest-dir=<dir>注意must-gather命令必须使用performance-addon-operator-must-gather镜像运行。输出可以被压缩(可选)。如果您正在运行性能配置集 Creator wrapper 脚本,则需要压缩输出。示例
$ oc adm must-gather --image=registry.redhat.io/openshift4/performance-addon-operator-must-gather-rhel8:v4.8 --dest-dir=must-gather从
must-gather目录创建一个压缩文件:$ tar cvaf must-gather.tar.gz must-gather/
19.1.2. 使用 podman 运行 Performance Profile Creator 复制链接链接已复制到粘贴板!
作为集群管理员,您可以运行 podman 和 Performance Profile Creator 来创建性能配置集。
先决条件
-
使用具有
cluster-admin角色的用户访问集群。 - 在裸机硬件上安装的集群。
-
安装了
podman和 OpenShift CLI(oc)的节点。
流程
检查机器配置池:
$ oc get mcp输出示例
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE master rendered-master-acd1358917e9f98cbdb599aea622d78b True False False 3 3 3 0 22h worker-cnf rendered-worker-cnf-1d871ac76e1951d32b2fe92369879826 False True False 2 1 1 0 22h使用 Podman 向
registry.redhat.io进行身份验证:$ podman login registry.redhat.ioUsername: myrhusername Password: ************可选:显示 PPC 工具的帮助信息:
$ podman run --entrypoint performance-profile-creator registry.redhat.io/openshift4/performance-addon-rhel8-operator:v4.8 -h输出示例
A tool that automates creation of Performance Profiles Usage: performance-profile-creator [flags] Flags: --disable-ht Disable Hyperthreading -h, --help help for performance-profile-creator --info string Show cluster information; requires --must-gather-dir-path, ignore the other arguments. [Valid values: log, json] (default "log") --mcp-name string MCP name corresponding to the target machines (required) --must-gather-dir-path string Must gather directory path (default "must-gather") --power-consumption-mode string The power consumption mode. [Valid values: default, low-latency, ultra-low-latency] (default "default") --profile-name string Name of the performance profile to be created (default "performance") --reserved-cpu-count int Number of reserved CPUs (required) --rt-kernel Enable Real Time Kernel (required) --split-reserved-cpus-across-numa Split the Reserved CPUs across NUMA nodes --topology-manager-policy string Kubelet Topology Manager Policy of the performance profile to be created. [Valid values: single-numa-node, best-effort, restricted] (default "restricted") --user-level-networking Run with User level Networking(DPDK) enabled以发现模式运行 Performance Profile Creator 工具:
注意发现模式使用
must-gather的输出来检查您的集群。生成的输出包括以下信息:- 使用分配的 CPU ID 进行 NUMA 单元分区
- 是否启用超线程
使用此信息,您可以为提供给 Performance Profile Creator 工具的部分参数设置适当的值。
$ podman run --entrypoint performance-profile-creator -v /must-gather:/must-gather:z registry.redhat.io/openshift4/performance-addon-rhel8-operator:v4.8 --info log --must-gather-dir-path /must-gather注意此命令使用性能配置集创建器作为
podman的新入口点。它将主机的must-gather数据映射到容器镜像,并调用所需的用户提供的配置集参数来生成my-performance-profile.yaml文件。-v选项可以是到以下的任一路径:-
must-gather输出目录 -
包含
must-gather解压缩 tarball 的现有目录
info选项要求值指定输出格式。可能的值有 log 和 JSON。JSON 格式被保留用于调试。运行
podman:$ podman run --entrypoint performance-profile-creator -v /must-gather:/must-gather:z registry.redhat.io/openshift4/performance-addon-rhel8-operator:v4.8 --mcp-name=worker-cnf --reserved-cpu-count=20 --rt-kernel=true --split-reserved-cpus-across-numa=false --topology-manager-policy=single-numa-node --must-gather-dir-path /must-gather --power-consumption-mode=ultra-low-latency > my-performance-profile.yaml注意Performance Profile Creator 参数显示在 Performance Profile Creator 参数表中。需要以下参数:
-
reserved-cpu-count -
mcp-name -
rt-kernel
本例中的
mcp-name参数根据oc get mcp命令的输出设置为worker-cnf。对于单节点 OpenShift(SNO),使用--mcp-name=master。-
查看创建的 YAML 文件:
$ cat my-performance-profile.yaml输出示例
apiVersion: performance.openshift.io/v2 kind: PerformanceProfile metadata: name: performance spec: additionalKernelArgs: - nmi_watchdog=0 - audit=0 - mce=off - processor.max_cstate=1 - intel_idle.max_cstate=0 - idle=poll cpu: isolated: 1,3,5,7,9,11,13,15,17,19-39,41,43,45,47,49,51,53,55,57,59-79 reserved: 0,2,4,6,8,10,12,14,16,18,40,42,44,46,48,50,52,54,56,58 nodeSelector: node-role.kubernetes.io/worker-cnf: "" numa: topologyPolicy: single-numa-node realTimeKernel: enabled: true应用生成的配置集:
注意在应用配置集前安装 Performance Addon Operator。
$ oc apply -f my-performance-profile.yaml
19.1.2.1. 如何运行 podman 创建性能配置集 复制链接链接已复制到粘贴板!
以下示例演示了如何运行 podman 来创建具有 20 个保留 CPU 的性能配置集,这些 CPU 将在 NUMA 节点之间拆分。
节点硬件配置:
- 80 个 CPU
- 启用超线程
- 两个 NUMA 节点
- 编号为偶数的 CPU 在 NUMA 节点 0 上运行,编号为奇数的 CPU 在 NUMA 节点 1 上运行
运行 podman 以创建性能配置集:
$ podman run --entrypoint performance-profile-creator -v /must-gather:/must-gather:z registry.redhat.io/openshift4/performance-addon-rhel8-operator:v4.8 --mcp-name=worker-cnf --reserved-cpu-count=20 --rt-kernel=true --split-reserved-cpus-across-numa=true --must-gather-dir-path /must-gather > my-performance-profile.yaml
创建的配置集在以下 YAML 中描述:
apiVersion: performance.openshift.io/v2
kind: PerformanceProfile
metadata:
name: performance
spec:
cpu:
isolated: 10-39,50-79
reserved: 0-9,40-49
nodeSelector:
node-role.kubernetes.io/worker-cnf: ""
numa:
topologyPolicy: restricted
realTimeKernel:
enabled: true
在这种情况下,在 NUMA 节点 0 上保留 10 个 CPU,NUMA 节点 1 上保留 10 个 CPU。
19.1.3. 运行性能配置集 Creator wrapper 脚本 复制链接链接已复制到粘贴板!
性能配置集打包程序脚本简化了性能配置文件 Creator(PPC)工具的运行。它隐藏了运行 podman 的复杂性并指定映射目录,它支持创建性能配置集。
先决条件
- 访问 Performance Addon Operator 镜像。
-
访问
must-gathertarball。
流程
在本地机器上创建一个文件,例如
run-perf-profile-creator.sh:$ vi run-perf-profile-creator.sh将以下代码粘贴到文件中:
#!/bin/bash readonly CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-podman} readonly CURRENT_SCRIPT=$(basename "$0") readonly CMD="${CONTAINER_RUNTIME} run --entrypoint performance-profile-creator" readonly IMG_EXISTS_CMD="${CONTAINER_RUNTIME} image exists" readonly IMG_PULL_CMD="${CONTAINER_RUNTIME} image pull" readonly MUST_GATHER_VOL="/must-gather" PAO_IMG="registry.redhat.io/openshift4/performance-addon-rhel8-operator:v4.8" MG_TARBALL="" DATA_DIR="" usage() { print "Wrapper usage:" print " ${CURRENT_SCRIPT} [-h] [-p image][-t path] -- [performance-profile-creator flags]" print "" print "Options:" print " -h help for ${CURRENT_SCRIPT}" print " -p Performance Addon Operator image" print " -t path to a must-gather tarball" ${IMG_EXISTS_CMD} "${PAO_IMG}" && ${CMD} "${PAO_IMG}" -h } function cleanup { [ -d "${DATA_DIR}" ] && rm -rf "${DATA_DIR}" } trap cleanup EXIT exit_error() { print "error: $*" usage exit 1 } print() { echo "$*" >&2 } check_requirements() { ${IMG_EXISTS_CMD} "${PAO_IMG}" || ${IMG_PULL_CMD} "${PAO_IMG}" || \ exit_error "Performance Addon Operator image not found" [ -n "${MG_TARBALL}" ] || exit_error "Must-gather tarball file path is mandatory" [ -f "${MG_TARBALL}" ] || exit_error "Must-gather tarball file not found" DATA_DIR=$(mktemp -d -t "${CURRENT_SCRIPT}XXXX") || exit_error "Cannot create the data directory" tar -zxf "${MG_TARBALL}" --directory "${DATA_DIR}" || exit_error "Cannot decompress the must-gather tarball" chmod a+rx "${DATA_DIR}" return 0 } main() { while getopts ':hp:t:' OPT; do case "${OPT}" in h) usage exit 0 ;; p) PAO_IMG="${OPTARG}" ;; t) MG_TARBALL="${OPTARG}" ;; ?) exit_error "invalid argument: ${OPTARG}" ;; esac done shift $((OPTIND - 1)) check_requirements || exit 1 ${CMD} -v "${DATA_DIR}:${MUST_GATHER_VOL}:z" "${PAO_IMG}" "$@" --must-gather-dir-path "${MUST_GATHER_VOL}" echo "" 1>&2 } main "$@"为这个脚本中的每个人添加执行权限:
$ chmod a+x run-perf-profile-creator.sh可选:显示
run-perf-profile-creator.sh命令用法:$ ./run-perf-profile-creator.sh -h预期输出
Wrapper usage: run-perf-profile-creator.sh [-h] [-p image][-t path] -- [performance-profile-creator flags] Options: -h help for run-perf-profile-creator.sh -p Performance Addon Operator image1 -t path to a must-gather tarball2 A tool that automates creation of Performance Profiles Usage: performance-profile-creator [flags] Flags: --disable-ht Disable Hyperthreading -h, --help help for performance-profile-creator --info string Show cluster information; requires --must-gather-dir-path, ignore the other arguments. [Valid values: log, json] (default "log") --mcp-name string MCP name corresponding to the target machines (required) --must-gather-dir-path string Must gather directory path (default "must-gather") --power-consumption-mode string The power consumption mode. [Valid values: default, low-latency, ultra-low-latency] (default "default") --profile-name string Name of the performance profile to be created (default "performance") --reserved-cpu-count int Number of reserved CPUs (required) --rt-kernel Enable Real Time Kernel (required) --split-reserved-cpus-across-numa Split the Reserved CPUs across NUMA nodes --topology-manager-policy string Kubelet Topology Manager Policy of the performance profile to be created. [Valid values: single-numa-node, best-effort, restricted] (default "restricted") --user-level-networking Run with User level Networking(DPDK) enabled注意有两个参数类型:
-
wrapper 参数,即
-h、-p和-t - PPC 参数
-
wrapper 参数,即
以发现模式运行性能配置集创建器工具:
注意发现模式使用
must-gather的输出来检查您的集群。生成的输出包括以下信息:- 使用分配的 CPU ID 进行 NUMA 单元分区
- 是否启用超线程
使用此信息,您可以为提供给 Performance Profile Creator 工具的部分参数设置适当的值。
$ ./run-perf-profile-creator.sh -t /must-gather/must-gather.tar.gz -- --info=log注意info选项要求值指定输出格式。可能的值有 log 和 JSON。JSON 格式被保留用于调试。检查机器配置池:
$ oc get mcp输出示例
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE master rendered-master-acd1358917e9f98cbdb599aea622d78b True False False 3 3 3 0 22h worker-cnf rendered-worker-cnf-1d871ac76e1951d32b2fe92369879826 False True False 2 1 1 0 22h创建性能配置集:
$ ./run-perf-profile-creator.sh -t /must-gather/must-gather.tar.gz -- --mcp-name=worker-cnf --reserved-cpu-count=2 --rt-kernel=true > my-performance-profile.yaml注意Performance Profile Creator 参数显示在 Performance Profile Creator 参数表中。需要以下参数:
-
reserved-cpu-count -
mcp-name -
rt-kernel
本例中的
mcp-name参数根据oc get mcp命令的输出设置为worker-cnf。对于单节点 OpenShift(SNO),使用--mcp-name=master。-
查看创建的 YAML 文件:
$ cat my-performance-profile.yaml输出示例
apiVersion: performance.openshift.io/v2 kind: PerformanceProfile metadata: name: performance spec: cpu: isolated: 1-39,41-79 reserved: 0,40 nodeSelector: node-role.kubernetes.io/worker-cnf: "" numa: topologyPolicy: restricted realTimeKernel: enabled: false应用生成的配置集:
注意在应用配置集前安装 Performance Addon Operator。
$ oc apply -f my-performance-profile.yaml
19.1.4. Performance Profile Creator 参数 复制链接链接已复制到粘贴板!
| 参数 | 描述 |
|---|---|
|
| 禁用超线程。
可能的值:
默认值: 警告
如果此参数设为 |
|
|
这会捕获集群信息,仅用于发现模式。发现模式还需要 可能的值:
默认: |
|
|
MCP 名称(如 |
|
| 必须收集目录路径。这个参数是必需的。
当用户使用 wrapper 脚本 |
|
| 电源功耗模式。 可能的值:
默认: |
|
|
要创建的性能配置集的名称。默认: |
|
| 保留 CPU 的数量。这个参数是必需的。 注意 这必须是一个自然数字。不允许使用 0 值。 |
|
| 启用实时内核。这个参数是必需的。
可能的值: |
|
| 将保留的 CPU 划分到 NUMA 节点。
可能的值:
默认值: |
|
| 要创建的性能配置集的 kubelet Topology Manager 策略。 可能的值:
默认: |
|
| 在启用了用户级别网络(DPDK)的情况下运行。
可能的值:
默认值: |