×

使用 `openshift-install` 程序为在裸机主机上预安装单节点 OpenShift 创建实时安装 ISO。有关下载安装程序的更多信息,请参阅“附加资源”部分中的“安装过程”。

安装程序采用种子镜像 URL 和其他输入(例如种子镜像的发行版本和用于安装过程的磁盘)并创建实时安装 ISO。然后,您可以使用实时安装 ISO 启动主机以开始预安装。预安装完成后,主机即可运送到远程站点进行最终的特定于站点的配置和部署。

以下是使用基于镜像的安装预安装单节点 OpenShift 集群的高级步骤

  • 生成种子镜像。

  • 使用 `openshift-install` 安装程序创建实时安装 ISO。

  • 使用实时安装 ISO 启动主机以预安装主机。

附加资源

为单节点基于镜像的 OpenShift 安装创建实时安装 ISO

您可以使用 `openshift-install` 程序将单节点 OpenShift 种子镜像 URL 和其他安装工件嵌入到实时安装 ISO 中。

有关 `image-based-installation-config.yaml` 清单规范的更多信息,请参阅“image-based-installation-config.yaml 清单的参考规范”部分。

先决条件
  • 您已从单节点 OpenShift 种子集群生成种子镜像。

  • 您已下载 `openshift-install` 程序。`openshift-install` 程序的版本必须与种子镜像中的 OpenShift Container Platform 版本匹配。

  • 目标主机可以访问种子镜像 URL 和所有其他安装工件。

  • 如果您需要静态网络,则必须在创建实时安装 ISO 的主机上安装 `nmstatectl` 库。

步骤
  1. 创建实时安装 ISO 并嵌入您的单节点 OpenShift 种子镜像 URL 和其他安装工件

    1. 通过运行以下命令创建一个工作目录

      $ mkdir ibi-iso-workdir (1)
      1 将 `ibi-iso-workdir` 替换为您工作目录的名称。
    2. 可选。创建一个安装配置模板,在配置 `ImageBasedInstallationConfig` 资源时用作参考

      $ openshift-install image-based create image-config-template --dir ibi-iso-workdir (1)
      1 如果您未指定工作目录,则该命令将使用当前目录。
      示例输出
      INFO Image-Config-Template created in: ibi-iso-workdir

      该命令会在您的目标目录中创建image-based-installation-config.yaml安装配置模板。

      #
      # Note: This is a sample ImageBasedInstallationConfig file showing
      # which fields are available to aid you in creating your
      # own image-based-installation-config.yaml file.
      #
      apiVersion: v1beta1
      kind: ImageBasedInstallationConfig
      metadata:
        name: example-image-based-installation-config
      # The following fields are required
      seedImage: quay.io/openshift-kni/seed-image:4.17.0
      seedVersion: 4.17.0
      installationDisk: /dev/vda
      pullSecret: '<your_pull_secret>'
      # networkConfig is optional and contains the network configuration for the host in NMState format.
      # See https://nmstate.io/examples.html for examples.
      # networkConfig:
      #   interfaces:
      #     - name: eth0
      #       type: ethernet
      #       state: up
      #       mac-address: 00:00:00:00:00:00
      #       ipv4:
      #         enabled: true
      #         address:
      #           - ip: 192.168.122.2
      #             prefix-length: 23
      #         dhcp: false
    3. 编辑您的安装配置文件。

      image-based-installation-config.yaml文件示例
      apiVersion: v1beta1
      kind: ImageBasedInstallationConfig
      metadata:
        name: example-image-based-installation-config
      seedImage: quay.io/repo-id/seed:latest
      seedVersion: "4.17.0"
      extraPartitionStart: "-240G"
      installationDisk: /dev/disk/by-id/wwn-0x62c...
      sshKey: 'ssh-ed25519 AAAA...'
      pullSecret: '{"auths": ...}'
      networkConfig:
          interfaces:
            - name: ens1f0
              type: ethernet
              state: up
              ipv4:
                enabled: true
                dhcp: false
                auto-dns: false
                address:
                  - ip: 192.168.200.25
                    prefix-length: 24
              ipv6:
                enabled: false
          dns-resolver:
            config:
              server:
                - 192.168.15.47
                - 192.168.15.48
          routes:
            config:
            - destination: 0.0.0.0/0
              metric: 150
              next-hop-address: 192.168.200.254
              next-hop-interface: ens1f0
    4. 运行以下命令创建实时安装 ISO。

      $ openshift-install image-based create image --dir ibi-iso-workdir
      示例输出
      INFO Consuming Image-based Installation ISO Config from target directory
      INFO Creating Image-based Installation ISO with embedded ignition
验证
  • 查看工作目录中的输出。

    ibi-iso-workdir/
      └── rhcos-ibi.iso

配置目标主机上的附加分区

作为基于映像的安装过程的一部分,安装 ISO 会为/var/lib/containers目录创建一个分区。

您可以使用coreosInstallerArgs规范创建附加分区。例如,对于具有足够存储空间的硬盘,您可能需要一个用于存储选项的附加分区,例如逻辑卷管理器 (LVM) 存储。

/var/lib/containers分区需要至少 500 GB 的空间,以确保为预缓存映像提供足够的磁盘空间。您必须创建起始位置大于/var/lib/containers分区的附加分区。

步骤
  1. 编辑image-based-installation-config.yaml文件以配置附加分区。

    image-based-installation-config.yaml文件示例
    apiVersion: v1beta1
    kind: ImageBasedInstallationConfig
    metadata:
      name: example-extra-partition
    seedImage: quay.io/repo-id/seed:latest
    seedVersion: "4.17.0"
    installationDisk: /dev/sda
    pullSecret: '{"auths": ...}'
    # ...
    skipDiskCleanup: true (1)
    coreosInstallerArgs:
       - "--save-partindex" (2)
       - "6" (3)
    ignitionConfigOverride: |
      {
        "ignition": {
          "version": "3.2.0"
        },
        "storage": {
          "disks": [
            {
              "device": "/dev/sda", (4)
              "partitions": [
                {
                  "label": "storage", (5)
                  "number": 6, (6)
                  "sizeMiB": 380000, (7)
                  "startMiB": 500000 (8)
                }
              ]
            }
          ]
        }
      }
    1 指定true以跳过安装过程中的磁盘格式化。
    2 指定此参数以保留分区。
    3 实时安装 ISO 需要五个分区。指定大于五的数字以标识要保留的附加分区。
    4 指定目标主机上的安装磁盘。
    5 指定分区的标签。
    6 指定分区的编号。
    7 指定分区的 MiB 大小。
    8 指定附加分区在磁盘上的起始位置 (MiB)。您必须指定一个大于var/lib/containers分区的起始点。
验证
  • 使用实时安装 ISO 完成主机的预安装后,登录到目标主机并运行以下命令以查看分区。

    $ lsblk
    示例输出
    sda    8:0    0  140G  0 disk
    ├─sda1 8:1    0    1M  0 part
    ├─sda2 8:2    0  127M  0 part
    ├─sda3 8:3    0  384M  0 part /var/mnt/boot
    ├─sda4 8:4    0  120G  0 part /var/mnt
    ├─sda5 8:5    0  500G  0 part /var/lib/containers
    └─sda6 8:6    0  380G  0 part

将实时安装 ISO 置备到主机

使用您首选的方法,从rhcos-ibi.iso实时安装 ISO 引导目标裸机主机以预安装单节点 OpenShift。

验证
  1. 登录到目标主机。

  2. 运行以下命令查看系统日志。

    $ journalctl -b
    示例输出
    Aug 13 17:01:44 10.46.26.129 install-rhcos-and-restore-seed.sh[2876]: time="2024-08-13T17:01:44Z" level=info msg="All the precaching threads have finished."
    Aug 13 17:01:44 10.46.26.129 install-rhcos-and-restore-seed.sh[2876]: time="2024-08-13T17:01:44Z" level=info msg="Total Images: 125"
    Aug 13 17:01:44 10.46.26.129 install-rhcos-and-restore-seed.sh[2876]: time="2024-08-13T17:01:44Z" level=info msg="Images Pulled Successfully: 125"
    Aug 13 17:01:44 10.46.26.129 install-rhcos-and-restore-seed.sh[2876]: time="2024-08-13T17:01:44Z" level=info msg="Images Failed to Pull: 0"
    Aug 13 17:01:44 10.46.26.129 install-rhcos-and-restore-seed.sh[2876]: time="2024-08-13T17:01:44Z" level=info msg="Completed executing pre-caching"
    Aug 13 17:01:44 10.46.26.129 install-rhcos-and-restore-seed.sh[2876]: time="2024-08-13T17:01:44Z" level=info msg="Pre-cached images successfully."
    Aug 13 17:01:44 10.46.26.129 install-rhcos-and-restore-seed.sh[2876]: time="2024-08-13 17:01:44" level=info msg="Skipping shutdown"
    Aug 13 17:01:44 10.46.26.129 install-rhcos-and-restore-seed.sh[2876]: time="2024-08-13 17:01:44" level=info msg="IBI preparation process finished successfully!"
    Aug 13 17:01:44 10.46.26.129 systemd[1]: var-lib-containers-storage-overlay.mount: Deactivated successfully.
    Aug 13 17:01:44 10.46.26.129 systemd[1]: Finished SNO Image-based Installation.
    Aug 13 17:01:44 10.46.26.129 systemd[1]: Reached target Multi-User System.
    Aug 13 17:01:44 10.46.26.129 systemd[1]: Reached target Graphical Interface.

image-based-installation-config.yaml清单的参考规范

以下内容描述了image-based-installation-config.yaml清单的规范。

openshift-install程序使用image-based-installation-config.yaml清单为单节点 OpenShift 的基于映像的安装创建实时安装 ISO。

表 1. 必需规范
规范 类型 描述

seedImage

字符串

指定在 ISO 生成过程中使用的种子映像。

seedVersion

字符串

指定种子映像的 OpenShift Container Platform 发行版版本。种子映像中的发行版版本必须与您在seedVersion字段中指定的版本匹配。

installationDisk

字符串

指定将用于安装过程的磁盘。

由于磁盘发现顺序并非保证,因此磁盘的内核名称在具有多个磁盘的机器的引导选项之间可能会发生变化。例如,/dev/sda变为/dev/sdb,反之亦然。为避免此问题,必须使用持久性磁盘属性,例如磁盘世界范围名称 (WWN),例如:/dev/disk/by-id/wwn-<disk-id>

pullSecret

字符串

指定在预缓存过程中使用的拉取密钥。拉取密钥包含从容器注册表拉取发行版有效负载映像的认证凭据。

如果种子映像需要单独的私有注册表身份验证,请将身份验证详细信息添加到拉取密钥。

表 2. 可选规范
规范 类型 描述

shutdown

布尔值

指定安装过程完成后主机是否关闭。默认值为false

extraPartitionStart

字符串

指定用于/var/lib/containers的额外分区的起始位置。默认值为-40Gb,这意味着分区的大小正好为 40Gb,并使用磁盘末尾的 40Gb 空间。如果指定正值,则分区将从磁盘的该位置开始,并扩展到磁盘的末尾。

extraPartitionLabel

字符串

您用于/var/lib/containers的额外分区的标签。默认分区标签为var-lib-containers

您必须确保安装 ISO 中的分区标签与种子映像的机器配置中设置的分区标签匹配。如果分区标签不同,则主机上的安装过程中分区挂载会失败。有关更多信息,请参阅“在 ostree stateroots 之间配置共享容器分区”。

extraPartitionNumber

无符号整数

您用于/var/lib/containers的额外分区的编号。默认编号为5

skipDiskCleanup

布尔值

安装过程会格式化主机上的磁盘。将此规范设置为“true”以跳过此步骤。默认为false

networkConfig

字符串

指定主机的网络配置,例如

networkConfig:
    interfaces:
      - name: ens1f0
        type: ethernet
        state: up
        ...

如果需要静态网络,则必须在创建实时安装 ISO 的主机上安装nmstatectl库。有关使用nmstate定义网络配置的更多信息,请参阅nmstate.io

接口名称必须与操作系统中显示的实际 NIC 名称匹配。

proxy

字符串

指定在安装 ISO 生成过程中使用的代理设置,例如

proxy:
  httpProxy: "http://proxy.example.com:8080"
  httpsProxy: "http://proxy.example.com:8080"
  noProxy: "no_proxy.example.com"

imageDigestSources

字符串

指定发行版映像内容的源或存储库,例如

imageDigestSources:
  - mirrors:
      - "registry.example.com:5000/ocp4/openshift4"
    source: "quay.io/openshift-release-dev/ocp-release"

additionalTrustBundle

字符串

指定 PEM 编码的 X.509 证书捆绑包。安装程序会将其添加到安装 ISO 中的/etc/pki/ca-trust/source/anchors/目录。

additionalTrustBundle: |
  -----BEGIN CERTIFICATE-----
  MTICLDCCAdKgAwfBAgIBAGAKBggqhkjOPQRDAjB9MQswCQYRVEQGE
  ...
  l2wOuDwKQa+upc4GftXE7C//4mKBNBC6Ty01gUaTIpo=
  -----END CERTIFICATE-----

sshKey

字符串

指定用于验证对主机的访问权限的 SSH 密钥。

ignitionConfigOverride

字符串

指定包含用户对 Ignition 配置的覆盖的 JSON 字符串。该配置与安装程序生成的 Ignition 配置文件合并。此功能需要 Ignition 版本 3.2 或更高版本。

coreosInstallerArgs

字符串

指定您可以用来配置内核参数和磁盘分区选项的coreos-install命令的自定义参数。