8.3.5. 创建 RHCOS 镜像缓存(可选)

要使用镜像缓存,您必须下载两个镜像:Bootstrap 虚拟机使用的 Red Hat Enterprise Linux CoreOS(RHCOS)镜像,以及安装程序用来置备不同节点的 RHCOS 镜像。镜像缓存是可选的,但在有限带宽的网络中运行安装程序时特别有用。

如果您在带有有限带宽的网络上运行安装程序,而 RHCOS 镜像下载时间超过 15 到 20 分钟,则安装程序会超时。在这样的情况下,可以将镜像缓存到网页服务器上。

使用以下步骤安装包含镜像的容器。

  1. 安装 podman

    $ sudo dnf install -y podman
  2. 打开防火墙端口 8080 以用于 RHCOS 镜像缓存。

    $ sudo firewall-cmd --add-port=8080/tcp --zone=public --permanent
    $ sudo firewall-cmd --reload
  3. 创建用于存储 bootstraposimageclusterosimage 的目录。

    $ mkdir /home/kni/rhcos_image_cache
  4. 为新创建的目录设置正确的 SELinux 上下文。

    $ sudo semanage fcontext -a -t httpd_sys_content_t "/home/kni/rhcos_image_cache(/.*)?"
    $ sudo restorecon -Rv rhcos_image_cache/
  5. 从安装程序获取提交 ID。这个 ID 决定了安装程序需要下载的镜像。

    $ export COMMIT_ID=$(/usr/local/bin/openshift-baremetal-install version | grep '^built from commit' | awk '{print $4}')
  6. 获取安装程序将部署到节点上的 RHCOS 镜像的 URI。

    $ export RHCOS_OPENSTACK_URI=$(curl -s -S https://raw.githubusercontent.com/openshift/installer/$COMMIT_ID/data/data/rhcos.json  | jq .images.openstack.path | sed 's/"//g')
  7. 获取安装程序要在 bootstrap 虚拟机上部署的 RHCOS 镜像的 URI。

    $ export RHCOS_QEMU_URI=$(curl -s -S https://raw.githubusercontent.com/openshift/installer/$COMMIT_ID/data/data/rhcos.json  | jq .images.qemu.path | sed 's/"//g')
  8. 获取发布镜像的路径。

    $ export RHCOS_PATH=$(curl -s -S https://raw.githubusercontent.com/openshift/installer/$COMMIT_ID/data/data/rhcos.json | jq .baseURI | sed 's/"//g')
  9. 获取要在 bootstrap 虚拟机上部署的 RHCOS 镜像的 SHA 哈希。

    $ export RHCOS_QEMU_SHA_UNCOMPRESSED=$(curl -s -S https://raw.githubusercontent.com/openshift/installer/$COMMIT_ID/data/data/rhcos.json  | jq -r '.images.qemu["uncompressed-sha256"]')
  10. 获取要在节点上部署的 RHCOS 镜像的 SHA 哈希。

    $ export RHCOS_OPENSTACK_SHA_COMPRESSED=$(curl -s -S https://raw.githubusercontent.com/openshift/installer/$COMMIT_ID/data/data/rhcos.json  | jq -r '.images.openstack.sha256')
  11. 下载这些镜像并将其放在 /home/kni/rhcos_image_cache 目录中。

    $ curl -L ${RHCOS_PATH}${RHCOS_QEMU_URI} -o /home/kni/rhcos_image_cache/${RHCOS_QEMU_URI}
    $ curl -L ${RHCOS_PATH}${RHCOS_OPENSTACK_URI} -o /home/kni/rhcos_image_cache/${RHCOS_OPENSTACK_URI}
  12. 对于新创建的文件,确认 SELinux 类型为 httpd_sys_content_t

    $ ls -Z /home/kni/rhcos_image_cache
  13. 创建 pod。

    $ podman run -d --name rhcos_image_cache \
    -v /home/kni/rhcos_image_cache:/var/www/html \
    -p 8080:8080/tcp \
    quay.io/centos7/httpd-24-centos7:latest