16.4.2. 关于单节点 OpenShift 的基于镜像的部署


您可以使用 openshift-install 程序手动生成配置 ISO。将配置 ISO 附加到预安装的目标主机以完成部署。

您可以使用 openshift-install 程序配置和部署预安装了基于镜像的安装的主机。要使用特定于站点的详情配置目标主机,您必须创建以下资源:

  • install-config.yaml 安装清单
  • image-based-config.yaml 清单

openshift-install 程序使用这些资源来生成一个配置 ISO,您将它附加到预安装的目标主机来完成部署。

注意

如需有关 image-based-config.yaml 清单规格的更多信息,请参阅"image-based-config.yaml manifest 清单参考规格"。

先决条件

  • 已使用基于镜像的安装,预安装了单节点 OpenShift 的主机。
  • 下载了 openshift-install 程序的最新版本。
  • 您创建了 pull secret 以验证拉取请求。如需更多信息,请参阅"使用镜像 pull secret"。

流程

  1. 运行以下命令来创建工作目录:

    $ mkdir ibi-config-iso-workdir 
    1
    1
    ibi-config-iso-workdir 替换为工作目录的名称。
  2. 创建安装清单:

    1. 创建定义 install-config 清单的 YAML 文件:

      install-config.yaml 文件示例

      apiVersion: v1
      metadata:
        name: sno-cluster-name
      baseDomain: host.example.com
      compute:
        - architecture: amd64
          hyperthreading: Enabled
          name: worker
          replicas: 0
      controlPlane:
        architecture: amd64
        hyperthreading: Enabled
        name: master
        replicas: 1
      networking:
        clusterNetwork:
        - cidr: 10.128.0.0/14
          hostPrefix: 23
        machineNetwork:
        - cidr: 192.168.200.0/24
        networkType: OVNKubernetes
        serviceNetwork:
        - 172.30.0.0/16
      platform:
        none: {}
      fips: false
      cpuPartitioningMode: "AllNodes"
      pullSecret: '{"auths":{"<your_pull_secret>"}}}'
      sshKey: 'ssh-rsa <your_ssh_pub_key>'

      重要

      如果您的集群部署需要代理配置,您必须执行以下操作:

      • 从带有代理配置的 seed 集群创建 seed 镜像。代理配置不必相互匹配。
      • 在安装清单中配置 machineNetwork 字段。
    2. 将文件保存到工作目录中。
  3. 可选。运行以下命令,在工作目录中创建配置模板:

    $ openshift-install image-based create config-template --dir ibi-config-iso-workdir/

    输出示例

    INFO Config-Template created in: ibi-config-iso-workdir

    该命令在工作目录中创建 image-based-config.yaml 配置模板:

    #
    # Note: This is a sample ImageBasedConfig file showing
    # which fields are available to aid you in creating your
    # own image-based-config.yaml file.
    #
    apiVersion: v1beta1
    kind: ImageBasedConfig
    metadata:
      name: example-image-based-config
    additionalNTPSources:
      - 0.rhel.pool.ntp.org
      - 1.rhel.pool.ntp.org
    hostname: change-to-hostname
    releaseRegistry: quay.io
    # networkConfig 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
  4. 编辑配置文件:

    image-based-config.yaml 文件示例

    #
    # Note: This is a sample ImageBasedConfig file showing
    # which fields are available to aid you in creating your
    # own image-based-config.yaml file.
    #
    apiVersion: v1beta1
    kind: ImageBasedConfig
    metadata:
      name: sno-cluster-name
    additionalNTPSources:
      - 0.rhel.pool.ntp.org
      - 1.rhel.pool.ntp.org
    hostname: host.example.com
    releaseRegistry: quay.io
    # networkConfig contains the network configuration for the host in NMState format.
    # See https://nmstate.io/examples.html for examples.
    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

  5. 运行以下命令,在工作目录中创建配置 ISO:

    $ openshift-install image-based create config-image --dir ibi-config-iso-workdir/

    输出示例

    INFO Adding NMConnection file <ens1f0.nmconnection>
    INFO Consuming Install Config from target directory
    INFO Consuming Image-based Config ISO configuration from target directory
    INFO Config-Image created in: ibi-config-iso-workdir/auth

    查看工作目录中的输出:

    输出示例

    ibi-config-iso-workdir/
    ├── auth
    │   ├── kubeadmin-password
    │   └── kubeconfig
    └── imagebasedconfig.iso

  6. 使用您首选的方法将 imagebasedconfig.iso 附加到预安装的主机,然后重新启动主机以完成配置过程并部署集群。

验证

当配置过程在主机上完成时,访问集群以验证其状态。

  1. 运行以下命令,将 kubeconfig 环境变量导出到 kubeconfig 文件中:

    $ export KUBECONFIG=ibi-config-iso-workdir/auth/kubeconfig
  2. 运行以下命令验证集群是否响应:

    $ oc get nodes

    输出示例

    NAME                                         STATUS   ROLES                  AGE     VERSION
    node/sno-cluster-name.host.example.com       Ready    control-plane,master   5h15m   v1.30.3

16.4.2.1.1. image-based-config.yaml 清单的规格参考

以下内容介绍了 image-based-config.yaml 清单的规格。

openshift-install 程序使用 image-based-config.yaml 清单为基于镜像的单节点 OpenShift 部署创建特定于站点的配置 ISO。

Expand
表 16.9. 所需的规格
规格类型描述

hostname

string

为单节点 OpenShift 集群定义节点的名称。

Expand
表 16.10. 可选规格
规格类型描述

networkConfig

string

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

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

如果需要静态网络,您必须在创建实时安装 ISO 的主机上安装 nmstatectl 库。有关使用 nmstate 定义网络配置的详情,请参考 nmstate.io

重要

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

additionalNTPSources

string

指定所有集群主机的 NTP 源列表。这些 NTP 源会添加到集群中的任何现有 NTP 源中。您可以将主机名或 IP 地址用于 NTP 源。

releaseRegistry

string

指定用于 seed 集群的发行镜像的容器镜像 registry。

nodeLabels

map[string]string

为单节点 OpenShift 节点指定自定义节点标签,例如:

nodeLabels:
  node-role.kubernetes.io/edge: true
  environment: production
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部