54 电信功能(DPDK、SR-IOV、CPU 隔离、大页、NUMA 等) #
定向网络配置工作流允许自动化在下游集群中使用的电信功能,以便在这些服务器上运行电信工作负载。
要求
使用
EIB生成的镜像(如 上一节 (第 49 章 “为连接场景准备下游集群镜像”) 所述)必须位于管理集群中,且路径必须与您在 本节 (注意) 中配置的路径完全一致。使用
EIB生成的镜像必须包含本节后面所述的特定电信软件包。管理服务器已创建,并可在以下部分中使用。有关更多信息,请参阅“管理集群”部分:第 V 部分 “设置管理集群”。
配置
使用以下两节作为注册和置备主机的基础:
使用定向网络配置进行下游集群置备(单节点) (第 51 章 “使用定向网络配置(单节点)进行下游集群配置”)
使用定向网络配置(多节点)进行下游集群置备 (第 52 章 “使用定向网络置备(多节点)进行下游集群置备”)
本节涵盖的电信功能如下:
DPDK 和 VF 创建
SR-IOV 和供工作负载使用的 VF 分配
CPU 隔离和性能调优
大页配置
内核参数调优
启用上述电信功能所需的更改均位于置备文件 capi-provisioning-example.yaml 中的 RKE2ControlPlane 块内。文件 capi-provisioning-example.yaml 内的其余信息与 置备部分 (第 51 章 “使用定向网络配置(单节点)进行下游集群配置”) 中提供的信息相同。
为使过程清晰,在该块 (RKE2ControlPlane) 上启用电信功能所需的更改如下:
用于定义接口、驱动程序以及要创建并暴露给工作负载的
VFs数量的 ignition 文件/var/lib/rancher/rke2/server/manifests/configmap-sriov-custom-auto.yaml。配置映射
sriov-custom-auto-config内的值是唯一需要替换为实际值的值。${RESOURCE_NAME1}— 用于第一个PF接口的资源名称(例如sriov-resource-du1)。它被添加到前缀rancher.io中,用作工作负载的标签(例如,rancher.io/sriov-resource-du1)。${SRIOV-NIC-NAME1}— 要使用的第一个PF接口的名称(例如eth0)。${PF_NAME1}— 要使用的第一个物理功能PF的名称。使用此项生成更复杂的过滤器(例如eth0#2-5)。${DRIVER_NAME1}— 用于第一个VF接口的驱动程序名称(例如vfio-pci)。${NUM_VFS1}— 为第一个PF接口创建的VFs数量(例如8)。
用作高级配置映射
sriov-custom-auto-config与包含底层硬件信息的sriovnetworknodepolicy之间转换器的/var/sriov-auto-filler.sh。创建此脚本是为了让用户无需预先了解硬件信息的复杂性。此文件无需更改,但如果我们需要启用sr-iov并创建VFs,则必须存在该文件。用于启用以下功能的内核参数:
参数 | 值 | 说明 |
isolcpus | domain,nohz,managed_irq,1-30,33-62 | 隔离核心 1-30 和 33-62。 |
skew_tick | 1 | 允许内核在隔离的 CPU 之间偏移定时器中断。 |
nohz | on | 允许内核在系统空闲时在单个 CPU 上运行定时器滴答。 |
nohz_full | 1-30,33-62 | 内核引导参数是目前配置完全动态时钟(full dynticks)以及 CPU 隔离的主要接口。 |
rcu_nocbs | 1-30,33-62 | 允许内核在系统空闲时在单个 CPU 上运行 RCU 回调。 |
irqaffinity | 0,31,32,63 | 允许内核在系统空闲时在单个 CPU 上运行中断。 |
空闲 | 巡回检测 | 最小化退出空闲状态的延迟。 |
iommu | pt | 允许将 vfio 用于 DPDK 接口。 |
intel_iommu | on | 启用对 VF 使用 vfio。 |
hugepagesz | 1G | 允许将大页的大小设置为 1 G。 |
hugepages | 40 | 之前定义的大页数量。 |
default_hugepagesz | 1G | 启用大页的默认值。 |
nowatchdog | 禁用看门狗。 | |
nmi_watchdog | 0 | 禁用 NMI 看门狗。 |
以下 systemd 服务用于启用以下功能:
rke2-preinstall.service在置备过程中使用 Ironic 信息自动替换BAREMETALHOST_UUID和node-name。cpu-partitioning.service用于启用CPU的隔离核心(例如1-30,33-62)。performance-settings.service用于启用 CPU 性能调优。sriov-custom-auto-vfs.service用于安装sriovHelm chart,等待自定义资源创建完成,并运行/var/sriov-auto-filler.sh以替换配置映射sriov-custom-auto-config中的值,并创建供工作负载使用的sriovnetworknodepolicy。
${RKE2_VERSION}是要使用的RKE2版本,用于替换此值(例如v1.35.4+rke2r1)。
提及所有这些更改后,capi-provisioning-example.yaml 中的 RKE2ControlPlane 块将如下所示:
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: RKE2ControlPlane
metadata:
name: single-node-cluster
namespace: default
spec:
infrastructureRef:
apiGroup: infrastructure.cluster.x-k8s.io
kind: Metal3MachineTemplate
name: single-node-cluster-controlplane
replicas: 1
version: ${RKE2_VERSION}
rolloutStrategy:
type: "RollingUpdate"
rollingUpdate:
maxSurge: 0
serverConfig:
cni: calico
cniMultusEnable: true
agentConfig:
format: ignition
additionalUserData:
config: |
variant: fcos
version: 1.4.0
storage:
files:
- path: /var/lib/rancher/rke2/server/manifests/configmap-sriov-custom-auto.yaml
overwrite: true
contents:
inline: |
apiVersion: v1
kind: ConfigMap
metadata:
name: sriov-custom-auto-config
namespace: kube-system
data:
config.json: |
[
{
"resourceName": "${RESOURCE_NAME1}",
"interface": "${SRIOV-NIC-NAME1}",
"pfname": "${PF_NAME1}",
"driver": "${DRIVER_NAME1}",
"numVFsToCreate": ${NUM_VFS1}
},
{
"resourceName": "${RESOURCE_NAME2}",
"interface": "${SRIOV-NIC-NAME2}",
"pfname": "${PF_NAME2}",
"driver": "${DRIVER_NAME2}",
"numVFsToCreate": ${NUM_VFS2}
}
]
mode: 0644
user:
name: root
group:
name: root
- path: /var/lib/rancher/rke2/server/manifests/sriov-crd.yaml
overwrite: true
contents:
inline: |
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: sriov-crd
namespace: kube-system
spec:
chart: oci://registry.suse.com/edge/charts/sriov-crd
targetNamespace: sriov-network-operator
version: 306.0.4+up1.6.0
createNamespace: true
- path: /var/lib/rancher/rke2/server/manifests/sriov-network-operator.yaml
overwrite: true
contents:
inline: |
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: sriov-network-operator
namespace: kube-system
spec:
chart: oci://registry.suse.com/edge/charts/sriov-network-operator
targetNamespace: sriov-network-operator
version: 306.0.4+up1.6.0
createNamespace: true
kernel_arguments:
should_exist:
- intel_iommu=on
- iommu=pt
- idle=poll
- mce=off
- hugepagesz=1G hugepages=40
- hugepagesz=2M hugepages=0
- default_hugepagesz=1G
- irqaffinity=${NON-ISOLATED_CPU_CORES}
- isolcpus=domain,nohz,managed_irq,${ISOLATED_CPU_CORES}
- nohz_full=${ISOLATED_CPU_CORES}
- rcu_nocbs=${ISOLATED_CPU_CORES}
- rcu_nocb_poll
- nosoftlockup
- nowatchdog
- nohz=on
- nmi_watchdog=0
- skew_tick=1
- quiet
systemd:
units:
- name: rke2-preinstall.service
enabled: true
contents: |
[Unit]
Description=rke2-preinstall
Wants=network-online.target
Before=rke2-install.service
ConditionPathExists=!/run/cluster-api/bootstrap-success.complete
[Service]
Type=oneshot
User=root
ExecStartPre=/bin/sh -c "mount -L config-2 /mnt"
ExecStart=/bin/sh -c "sed -i \"s/BAREMETALHOST_UUID/$(jq -r .uuid /mnt/openstack/latest/meta_data.json)/\" /etc/rancher/rke2/config.yaml"
ExecStart=/bin/sh -c "echo \"node-name: $(jq -r .name /mnt/openstack/latest/meta_data.json)\" >> /etc/rancher/rke2/config.yaml"
ExecStart=/bin/sh -c "echo \"node-label:\" >> /etc/rancher/rke2/config.yaml"
ExecStart=/bin/sh -c "echo \" - metal3.io/uuid=$(jq -r .uuid /mnt/openstack/latest/meta_data.json)\" >> /etc/rancher/rke2/config.yaml"
ExecStartPost=/bin/sh -c "umount /mnt"
[Install]
WantedBy=multi-user.target
# rke2-traefik-deployment.service unit to be removed once "traefik" being the default ingress controller (starting with RKE2 v1.36)
- name: rke2-traefik-deployment.service
enabled: true
contents: |
[Unit]
Description=rke2-traefik-deployment
Wants=rke2-preinstall.service
Before=rke2-install.service
ConditionPathExists=!/run/cluster-api/bootstrap-success.complete
[Service]
Type=oneshot
User=root
ExecStart=/bin/sh -c "echo \"ingress-controller: traefik\" >> /etc/rancher/rke2/config.yaml"
[Install]
WantedBy=multi-user.target
- name: cpu-partitioning.service
enabled: true
contents: |
[Unit]
Description=cpu-partitioning
Wants=network-online.target
After=network.target network-online.target
[Service]
Type=oneshot
User=root
ExecStart=/bin/sh -c "echo isolated_cores=${ISOLATED_CPU_CORES} > /etc/tuned/cpu-partitioning-variables.conf"
ExecStartPost=/bin/sh -c "tuned-adm profile cpu-partitioning"
ExecStartPost=/bin/sh -c "systemctl enable tuned.service"
[Install]
WantedBy=multi-user.target
- name: performance-settings.service
enabled: true
contents: |
[Unit]
Description=performance-settings
Wants=network-online.target
After=network.target network-online.target cpu-partitioning.service
[Service]
Type=oneshot
User=root
ExecStart=/bin/sh -c "/opt/performance-settings/performance-settings.sh"
[Install]
WantedBy=multi-user.target
- name: sriov-custom-auto-vfs.service
enabled: true
contents: |
[Unit]
Description=SRIOV Custom Auto VF Creation
Wants=network-online.target rke2-server.target
After=network.target network-online.target rke2-server.target
[Service]
User=root
Type=forking
TimeoutStartSec=900
ExecStart=/bin/sh -c "while ! /var/lib/rancher/rke2/bin/kubectl --kubeconfig=/etc/rancher/rke2/rke2.yaml wait --for condition=ready nodes --all ; do sleep 2 ; done"
ExecStartPost=/bin/sh -c "while [ $(/var/lib/rancher/rke2/bin/kubectl --kubeconfig=/etc/rancher/rke2/rke2.yaml get sriovnetworknodestates.sriovnetwork.openshift.io --ignore-not-found --no-headers -A | wc -l) -eq 0 ]; do sleep 1; done"
ExecStartPost=/bin/sh -c "/opt/sriov/sriov-auto-filler.sh"
RemainAfterExit=yes
KillMode=process
[Install]
WantedBy=multi-user.target
kubelet:
extraArgs:
- provider-id=metal3://BAREMETALHOST_UUID
nodeName: "localhost.localdomain"一旦通过连接前面的块创建了文件,就必须在管理集群中执行以下命令,以开始使用 Telco 功能置备新的下游集群:
$ kubectl apply -f capi-provisioning-example.yaml