×

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

使用 openshift-install 程序部署单节点 OpenShift 集群

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

  • install-config.yaml安装清单

  • image-based-config.yaml清单

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

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

先决条件
  • 您使用基于镜像的安装预安装了具有单节点 OpenShift 的主机。

  • 您下载了最新版本的openshift-install程序。

  • 您创建了一个拉取密钥来验证拉取请求。有关更多信息,请参阅“使用镜像拉取密钥”。

步骤
  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>'

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

      • 从具有代理配置的种子集群创建种子镜像。代理配置不必匹配。

      • 在您的安装清单中配置 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

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

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

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

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

hostname

字符串

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

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

networkConfig

字符串

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

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

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

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

additionalNTPSources

字符串

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

releaseRegistry

字符串

指定您用于种子集群的发布镜像的容器镜像注册表。

nodeLabels

map[string]string

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

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

配置额外清单的资源

您可以选择在单节点 OpenShift 集群的基于镜像的部署中定义其他资源。

在与包含install-config.yamlimage-based-config.yaml清单的同一工作目录中,在extra-manifests文件夹中创建其他资源。

extra-manifests目录中附加资源的文件名不得超过 30 个字符。更长的文件名可能会导致部署失败。

在 extra-manifests 文件夹中创建资源

您可以在工作目录的extra-manifests文件夹中创建一个资源,以将额外的清单添加到单节点 OpenShift 集群的基于镜像的部署中。

以下示例将单根 I/O 虚拟化 (SR-IOV) 网络添加到部署中。

先决条件
  • 您创建了一个包含install-config.yamlimage-based-config.yaml清单的工作目录

步骤
  1. 转到您的工作目录,并通过运行以下命令创建extra-manifests文件夹

    $ mkdir extra-manifests
  2. extra-manifests文件夹中创建SriovNetworkNodePolicySriovNetwork资源

    1. 创建一个定义资源的 YAML 文件

      sriov-extra-manifest.yaml文件示例
      apiVersion: sriovnetwork.openshift.io/v1
      kind: SriovNetworkNodePolicy
      metadata:
        name: "example-sriov-node-policy"
        namespace: openshift-sriov-network-operator
      spec:
        deviceType: vfio-pci
        isRdma: false
        nicSelector:
          pfNames: [ens1f0]
        nodeSelector:
          node-role.kubernetes.io/master: ""
        mtu: 1500
        numVfs: 8
        priority: 99
        resourceName: example-sriov-node-policy
      ---
      apiVersion: sriovnetwork.openshift.io/v1
      kind: SriovNetwork
      metadata:
        name: "example-sriov-network"
        namespace: openshift-sriov-network-operator
      spec:
        ipam: |-
          {
          }
        linkState: auto
        networkNamespace: sriov-namespace
        resourceName: example-sriov-node-policy
        spoofChk: "on"
        trust: "off"
验证
  • 创建配置 ISO 时,您可以在工作目录中的.openshift_install_state.json文件中查看对额外清单的引用

     "*configimage.ExtraManifests": {
            "FileList": [
                {
                    "Filename": "extra-manifests/sriov-extra-manifest.yaml",
                    "Data": "YXBFDFFD..."
                }
            ]
        }