50 为连接场景准备下游集群镜像 #
Edge Image Builder (第 12 章 “Edge Image Builder”) 用于准备修改后的 SLEMicro 基础镜像,该镜像部署在下游集群主机上。
通过 Edge Image Builder 可以进行大部分配置,但在本指南中,我们仅涵盖设置下游集群所需的最少配置。
50.1 连接场景的先决条件 #
运行 Edge Image Builder 需要容器运行时,例如 Podman 或 Rancher Desktop。
基础镜像将使用以下指南 第 65 章 “使用 Kiwi 构建更新的 SUSE Linux Micro 镜像” 和配置文件
Base(或Base-RT(针对实时内核))进行构建。两种架构(x86-64 和 aarch64)的处理相同。
必须使用与所构建镜像架构相同的构建主机。换句话说,要构建 aarch64 镜像,必须使用 aarch64 构建主机,反之亦然,对于 x86-64 也是如此(目前不支持交叉构建)。
50.2 连接场景的镜像配置 #
运行 Edge Image Builder 时,会从主机挂载一个目录,因此有必要创建一个目录结构来存储用于定义目标镜像的配置文件。
downstream-cluster-config.yaml是镜像定义文件,有关更多详细信息,请参阅 第 5 章 “使用 Edge Image Builder 的独立集群”。基础镜像文件夹将包含按照指南 第 65 章 “使用 Kiwi 构建更新的 SUSE Linux Micro 镜像” 和控制文件
Base(或Base-RT,用于实时内核)生成的输出原始镜像,必须将其复制/移动到base-images文件夹下。custom/files目录包含在镜像创建过程中要复制到镜像的performance-settings.sh和sriov-auto-filler.sh文件。custom/scripts目录包含要在首次启动时运行的脚本:01-fix-growfs.sh脚本是部署时调整操作系统根分区大小所必需的。02-performance.sh脚本是可选的,可用于配置系统以进行性能调优。03-sriov.sh脚本是可选的,可用于配置系统以实现 SR-IOV。
network文件夹是可选的,有关更多详细信息,请参阅 第 50.2.6 节 “用于高级网络配置的附加脚本”。os-files文件夹包含必要的配置文件,用于在每个节点启动时加载带有所需选项的sctp和vfio-pci内核模块。
├── downstream-cluster-config.yaml
├── base-images
│ └── SL-Micro.x86_64-6.2-Base-GM.raw
├── custom
│ ├── files
│ │ ├── performance-settings.sh
│ │ └── sriov-auto-filler.sh
│ └── scripts
│ ├── 01-fix-growfs.sh
│ ├── 02-performance.sh
│ └── 03-sriov.sh
├── network
│ └── configure-network.sh
└── os-files
└── etc
├── modprobe.d
│ └── vfio-pci-options.conf
└── modules-load.d
├── sctp.conf
└── vfio-pci.conf50.2.1 下游集群镜像定义文件 #
`downstream-cluster-config.yaml`文件是下游集群映像的主配置文件。以下是通过 Metal3 进行部署的最小示例:
apiVersion: 1.3
image:
imageType: raw
arch: x86_64
baseImage: SL-Micro.x86_64-6.2-Base-GM.raw
outputImageName: eibimage-output-telco.raw
operatingSystem:
kernelArgs:
- ignition.platform.id=openstack
systemd:
disable:
- rebootmgr
- transactional-update.timer
- transactional-update-cleanup.timer
- fstrim
- time-sync.target
users:
- username: root
encryptedPassword: $ROOT_PASSWORD
sshKeys:
- $USERKEY1
createHomeDir: true
packages:
packageList:
- jq
sccRegistrationCode: $SCC_REGISTRATION_CODE其中 $SCC_REGISTRATION_CODE 是从 SUSE Customer Center 复制的注册码,软件包列表包含所需的 jq。
$ROOT_PASSWORD 是 root 用户的加密密码,这对于测试/调试很有用。 它可以使用 openssl passwd -6 PASSWORD 命令生成
对于生产环境,建议使用可以添加到用户块中的 SSH 密钥,并将 $USERKEY1 替换为真实的 SSH 密钥。
arch: x86_64 是镜像的架构。对于 arm64 架构,请使用 arch: aarch64。
请注意 ignition.platform.id=openstack 是强制性的,如果没有此参数,SLEMicro 通过 ignition 的配置将在 Metal3 自动化流程中失败。
对于早于 6.2 的 SUSE Linux Micro 版本,必须将 net.ifnames=1 显式设置为内核参数,以启用 可预测网络接口命名。从 6.2 版本开始,此项默认强制执行,无需进行显式配置。这与管理集群 Metal3 Helm chart 中的 predictableNicNames 配置一致,这是定向网络配置正常运行所必需的。当使用 SR-IOV 时,一致的网络接口命名也至关重要。
50.2.2 Growfs 脚本 #
目前,需要一个自定义脚本 (custom/scripts/01-fix-growfs.sh) 来在配置后的首次启动时扩展文件系统以匹配磁盘大小。01-fix-growfs.sh 脚本包含以下信息:
#!/bin/bash
growfs() {
mnt="$1"
dev="$(findmnt --fstab --target ${mnt} --evaluate --real --output SOURCE --noheadings)"
# /dev/sda3 -> /dev/sda, /dev/nvme0n1p3 -> /dev/nvme0n1
parent_dev="/dev/$(lsblk --nodeps -rno PKNAME "${dev}")"
# Last number in the device name: /dev/nvme0n1p42 -> 42
partnum="$(echo "${dev}" | sed 's/^.*[^0-9]\([0-9]\+\)$/\1/')"
ret=0
growpart "$parent_dev" "$partnum" || ret=$?
[ $ret -eq 0 ] || [ $ret -eq 1 ] || exit 1
/usr/lib/systemd/systemd-growfs "$mnt"
}
growfs /50.2.3 性能脚本 #
可以使用以下可选脚本 (custom/scripts/02-performance.sh) 来配置系统以进行性能调优:
#!/bin/bash
# create the folder to extract the artifacts there
mkdir -p /opt/performance-settings
# copy the artifacts
cp performance-settings.sh /opt/performance-settings/custom/files/performance-settings.sh 的内容是一个可用于配置系统以进行性能调优的脚本,可以从以下 链接 下载。
50.2.4 SR-IOV 脚本 #
可以使用以下可选脚本 (custom/scripts/03-sriov.sh) 来配置系统以进行 SR-IOV:
#!/bin/bash
# create the folder to extract the artifacts there
mkdir -p /opt/sriov
# copy the artifacts
cp sriov-auto-filler.sh /opt/sriov/sriov-auto-filler.shcustom/files/sriov-auto-filler.sh 的内容是一个可用于配置系统以进行 SR-IOV 的脚本,可以从以下 链接 下载。
50.2.5 电信工作负载的附加配置 #
要启用 dpdk、sr-iov 或 FEC 等电信功能,可能需要如下例所示的附加软件包。
apiVersion: 1.3
image:
imageType: raw
arch: x86_64
baseImage: SL-Micro.x86_64-6.2-Base-GM.raw
outputImageName: eibimage-output-telco.raw
operatingSystem:
kernelArgs:
- ignition.platform.id=openstack
systemd:
disable:
- rebootmgr
- transactional-update.timer
- transactional-update-cleanup.timer
- fstrim
- time-sync.target
users:
- username: root
encryptedPassword: $ROOT_PASSWORD
sshKeys:
- $user1Key1
createHomeDir: true
packages:
packageList:
- jq # Non Telco specific - category: testing/utils
- dpdk # TelCo Core-Network UserPlane (5G UPF) and RAN UserPlane (gNB: DU and CU-UP) - category: runtime
- dpdk-tools # TelCo Core-Network UserPlane (5G UPF) and RAN UserPlane (gNB: DU and CU-UP) - category: testing/utils
- libdpdk-25 # TelCo Core-Network UserPlane (5G UPF) and RAN UserPlane (gNB: DU and CU-UP) - category: runtime
- pf-bb-config # TelCo RAN (gNB: DU) - category: config.
- open-iscsi # Non Telco specific (required by SUSE Storage/Longhorn) - category: runtime
- tuned # Non Telco specific (linux tuning) - category: config.
- cpupower # Non Telco specific (linux tuning - CPU power related settings) - category: config.
- rt-tests # Non Telco specific (RT scheduler-latency testing) - category: testing/utils
- linuxptp # TelCo RAN; time sync (gNB: DU) - category: runtime
- synce4l # TelCo RAN; time sync (gNN: DU) - category: runtime
- pciutils # Non Telco specific (provides "lspci" command) - category: testing/utils
- numactl # Non Telco specific (provides "numactl" command) - category: testing/utils
sccRegistrationCode: $SCC_REGISTRATION_CODE其中 $SCC_REGISTRATION_CODE 是从 SUSE 客户中心 复制的注册码,软件包列表包含用于电信配置文件的最少软件包。
arch: x86_64 是镜像的架构。对于 arm64 架构,请使用 arch: aarch64。
50.2.6 用于高级网络配置的附加脚本 #
如果您需要配置静态 IP 或 第 54 章 “高级网络配置” 中描述的更高级的网络场景,则需要进行以下附加配置。
在 network 文件夹中,创建以下 configure-network.sh 文件 - 这会在首次启动时使用配置驱动器数据,并使用 NM Configurator 工具 配置主机网络。
#!/bin/bash
set -eux
# Attempt to statically configure a NIC in the case where we find a network_data.json
# In a configuration drive
CONFIG_DRIVE=$(blkid --label config-2 || true)
if [ -z "${CONFIG_DRIVE}" ]; then
echo "No config-2 device found, skipping network configuration"
exit 0
fi
mount -o ro $CONFIG_DRIVE /mnt
META_DATA_FILE="/mnt/openstack/latest/meta_data.json"
if [ ! -f "${META_DATA_FILE}" ]; then
umount /mnt
echo "No meta_data.json found, skipping hostname configuration"
exit 0
fi
DESIRED_HOSTNAME=$(cat /mnt/openstack/latest/meta_data.json | tr ',{}' '\n' | grep '"metal3-name"' | sed 's/.*\"metal3-name\": \"\(.*\)\"/\1/')
echo "${DESIRED_HOSTNAME}" > /etc/hostname
NETWORK_DATA_FILE="/mnt/openstack/latest/network_data.json"
if [ ! -f "${NETWORK_DATA_FILE}" ]; then
umount /mnt
echo "No network_data.json found, skipping network configuration"
exit 0
fi
mkdir -p /tmp/nmc/{desired,generated}
cp ${NETWORK_DATA_FILE} /tmp/nmc/desired/_all.yaml
umount /mnt
./nmc generate --config-dir /tmp/nmc/desired --output-dir /tmp/nmc/generated
./nmc apply --config-dir /tmp/nmc/generated50.2.7 电信工作负载所需的内核模块 #
为确保在每个节点启动时加载电信工作负载所需的内核模块,必须将以下配置文件添加到 os-files EIB 文件夹中:
50.2.7.1 sctp.conf #
放置在 os-files/etc/modules-load.d/ 路径中,指示 systemd-modules-load.service 在节点启动时加载 sctp 内核模块。
$ cat os-files/etc/modules-load.d/sctp.conf
# Request "systemd-modules-load.service" to load sctp module at boot time
sctp50.2.7.2 vfio-pci.conf #
放置在 os-files/etc/modules-load.d/ 路径中,指示 systemd-modules-load.service 在节点启动时加载 vfio-pci 内核模块。
$ cat os-files/etc/modules-load.d/vfio-pci.conf
# Request "systemd-modules-load.service" to load vfio-pci module at boot time
# NOTE: The (SRIOV & DPDK related) required load-module options settings are defined in related "/etc/modprobe.d/vfio-pci-options.conf" file
vfio_pci50.2.7.3 vfio-pci-options.conf #
放置在 os-files/etc/modprobe.d/ 路径中,设置在加载内核模块时要应用的所需 vfio-pci 内核模块参数。
$ cat os-files/etc/modprobe.d/vfio-pci-options.conf
# Enable SR-IOV and disable idle D3 state for vfio-pci driver
options vfio_pci enable_sriov=1 disable_idle_d3=150.3 映像创建 #
一旦按照前几节准备好目录结构,请运行以下命令来构建映像:
podman run --rm --privileged -it -v $PWD:/eib \
registry.suse.com/edge/3.7/edge-image-builder:1.3.4 \
build --definition-file downstream-cluster-config.yaml这将基于上述定义创建名为 eibimage-output-telco.raw 的输出 RAW 映像文件。
然后,必须通过 Web 服务器提供输出映像,该服务器可以是 管理集群文档 (注意) 中启用的 media-server 容器,也可以是其他本地可访问的服务器。 在以下示例中,我们将此服务器称为 imagecache.local:8080