3.8. 可选:创建 RHCOS 镜像缓存
要使用镜像缓存,您必须下载 bootstrap 虚拟机使用的 Red Hat Enterprise Linux CoreOS(RHCOS)镜像,以置备集群节点。镜像缓存是可选的,但在有限带宽的网络中运行安装程序时特别有用。
安装程序不再需要 clusterOSImage
RHCOS 镜像,因为正确的镜像位于发行版本有效负载中。
如果您在带有有限带宽的网络中运行安装程序,且 RHCOS 镜像下载时间超过 15 到 20 分钟,安装程序会超时。在这种情况下,将映像缓存到 Web 服务器上将有所帮助。
如果为 HTTPD 服务器启用 TLS,您必须确认 root 证书由客户端信任的颁发机构签名,并验证 OpenShift Container Platform hub 和 spoke 集群和 HTTPD 服务器之间的可信证书链。使用配置了不受信任的证书的服务器可防止将镜像下载到创建镜像中。不支持使用不受信任的 HTTPS 服务器。
安装包含镜像的容器。
流程
安装
podman
:$ sudo dnf install -y podman
打开防火墙端口
8080
以用于 RHCOS 镜像缓存:$ sudo firewall-cmd --add-port=8080/tcp --zone=public --permanent
$ sudo firewall-cmd --reload
创建用于存储
bootstraposimage
的目录:$ mkdir /home/kni/rhcos_image_cache
为新创建的目录设置适当的 SELinux 上下文:
$ sudo semanage fcontext -a -t httpd_sys_content_t "/home/kni/rhcos_image_cache(/.*)?"
$ sudo restorecon -Rv /home/kni/rhcos_image_cache/
获取安装程序要在 bootstrap 虚拟机上部署的 RHCOS 镜像的 URI:
$ export RHCOS_QEMU_URI=$(/usr/local/bin/openshift-baremetal-install coreos print-stream-json | jq -r --arg ARCH "$(arch)" '.architectures[$ARCH].artifacts.qemu.formats["qcow2.gz"].disk.location')
获取安装程序要在 bootstrap 虚拟机上部署的镜像名称:
$ export RHCOS_QEMU_NAME=${RHCOS_QEMU_URI##*/}
获取要在 bootstrap 虚拟机上部署的 RHCOS 镜像的 SHA 哈希:
$ export RHCOS_QEMU_UNCOMPRESSED_SHA256=$(/usr/local/bin/openshift-baremetal-install coreos print-stream-json | jq -r --arg ARCH "$(arch)" '.architectures[$ARCH].artifacts.qemu.formats["qcow2.gz"].disk["uncompressed-sha256"]')
下载镜像并将其放在
/home/kni/rhcos_image_cache
目录中:$ curl -L ${RHCOS_QEMU_URI} -o /home/kni/rhcos_image_cache/${RHCOS_QEMU_NAME}
为新文件确认 SELinux 类型为
httpd_sys_content_t
:$ ls -Z /home/kni/rhcos_image_cache
创建 pod:
$ podman run -d --name rhcos_image_cache \1 -v /home/kni/rhcos_image_cache:/var/www/html \ -p 8080:8080/tcp \ registry.access.redhat.com/ubi9/httpd-24
- 1
- 创建名为
rhcos_image_cache
的缓存 webserver。此 pod 在install-config.yaml
文件中为部署提供bootstrapOSImage
镜像。
生成
bootstrapOSImage
配置:$ export BAREMETAL_IP=$(ip addr show dev baremetal | awk '/inet /{print $2}' | cut -d"/" -f1)
$ export BOOTSTRAP_OS_IMAGE="http://${BAREMETAL_IP}:8080/${RHCOS_QEMU_NAME}?sha256=${RHCOS_QEMU_UNCOMPRESSED_SHA256}"
$ echo " bootstrapOSImage=${BOOTSTRAP_OS_IMAGE}"
在 platform.
baremetal
下将所需的配置添加到install-config.yaml
文件中:platform: baremetal: bootstrapOSImage: <bootstrap_os_image> 1
- 1
- 将
<bootstrap_os_image>
替换为$BOOTSTRAP_OS_IMAGE
的值。
如需了解更多详细信息,请参阅"配置 install-config.yaml 文件"部分。