3.9. 使用 FDO 为 RHEL 系统部署镜像模式
您可以使用 FIDO Device Onboarding (FDO)为 RHEL 系统部署镜像模式,以向这个系统提供配置。使用 Kickstart 文件配置安装过程的各个部分,如设置用户、自定义分区和添加 SSH 密钥。您可以在 ISO 构建中包含 Kickstart 文件来配置安装过程的任何部分,但部署基础镜像除外。
如果您将 ISO 与 bootc 容器镜像搭配使用,则 bootc-image-builder 会自动安装
ostreecontainer
,这是安装容器镜像的命令。您仍然可以配置任何内容,但 ostreecontainer
命令除外。
先决条件
- 您已在主机机器上安装了 Podman。
-
您有 root 访问权限来运行
bootc-image-builder
工具,并在特权模式下运行
容器。 - 您已部署了 FDO 服务器基础架构。
流程
创建一个 Containerfile,例如:
FROM registry.redhat.io/rhel10/rhel-bootc:latest RUN dnf install -y fdo-init fdo-client RUN systemctl enable fdo-client-linuxapp.service
FROM registry.redhat.io/rhel10/rhel-bootc:latest RUN dnf install -y fdo-init fdo-client RUN systemctl enable fdo-client-linuxapp.service
Copy to Clipboard Copied! 创建 Kickstart 文件。以下 Kickstart 文件是一个完全无人值守的 Kickstart 文件配置示例,其中包含用户创建和分区说明。
[customizations.installer.kickstart] contents = """ text --non-interactive zerombr clearpart --all --initlabel --disklabel=gpt autopart --noswap --type=lvm user --name=test --groups=wheel --plaintext --password=test sshkey --username=test "ssh-ed25519 AAA..." network --bootproto=dhcp --device=link --activate --onboot=on poweroff %post export MANUFACTURING_SERVER_URL="http://192.168……" export DIUN_PUB_KEY_INSECURE="true" /usr/libexec/fdo/fdo-manufacturing-client %end """
[customizations.installer.kickstart] contents = """ text --non-interactive zerombr clearpart --all --initlabel --disklabel=gpt autopart --noswap --type=lvm user --name=test --groups=wheel --plaintext --password=test sshkey --username=test "ssh-ed25519 AAA..." network --bootproto=dhcp --device=link --activate --onboot=on poweroff %post export MANUFACTURING_SERVER_URL="http://192.168……" export DIUN_PUB_KEY_INSECURE="true" /usr/libexec/fdo/fdo-manufacturing-client %end """
Copy to Clipboard Copied! 在 export & lt;MANUFACTURING_SERVER_URL > 字段中,将 manufacturing 服务器 URL 替换为您自己的 manufacturing 服务器 URL。
-
以
.toml
格式保存 Kickstart 配置,以注入 Kickstart 内容。例如,config.toml
。 创建以下文件夹:
mkdir $(pwd)/output"
$ mkdir $(pwd)/output"
Copy to Clipboard Copied! 运行
bootc-image-builder
,并包含您要添加到 ISO 构建的 Kickstart 文件配置。bootc-image-builder
会自动添加安装容器镜像的 ostree
container 命令。sudo podman run \ --rm \ -it \ --privileged \ --pull=newer \ --security-opt label=type:unconfined_t \ -v /var/lib/containers/storage:/var/lib/containers/storage \ -v $(pwd)/config.toml:/config.toml \ -v $(pwd)/output:/output \ registry.redhat.io/rhel10/bootc-image-builder:latest \ --type iso \ --config /config.toml \ quay.io/<namespace>/<image>:<tag>
$ sudo podman run \ --rm \ -it \ --privileged \ --pull=newer \ --security-opt label=type:unconfined_t \ -v /var/lib/containers/storage:/var/lib/containers/storage \ -v $(pwd)/config.toml:/config.toml \ -v $(pwd)/output:/output \ registry.redhat.io/rhel10/bootc-image-builder:latest \ --type iso \ --config /config.toml \ quay.io/<namespace>/<image>:<tag>
Copy to Clipboard Copied! 您可以在输出文件夹中找到生成的
.iso
镜像。