16.4.2. 关于单节点 OpenShift 的基于镜像的部署
您可以使用 openshift-install 程序手动生成配置 ISO。将配置 ISO 附加到预安装的目标主机以完成部署。
16.4.2.1. 使用 openshift-install 程序部署单节点 OpenShift 集群 复制链接链接已复制到粘贴板!
您可以使用 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"。
流程
运行以下命令来创建工作目录:
$ mkdir ibi-config-iso-workdir1 - 1
- 将
ibi-config-iso-workdir替换为工作目录的名称。
创建安装清单:
创建定义
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 字段。
- 将文件保存到工作目录中。
可选。运行以下命令,在工作目录中创建配置模板:
$ 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编辑配置文件:
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运行以下命令,在工作目录中创建配置 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-
使用您首选的方法将
imagebasedconfig.iso附加到预安装的主机,然后重新启动主机以完成配置过程并部署集群。
验证
当配置过程在主机上完成时,访问集群以验证其状态。
运行以下命令,将
kubeconfig环境变量导出到 kubeconfig 文件中:$ export KUBECONFIG=ibi-config-iso-workdir/auth/kubeconfig运行以下命令验证集群是否响应:
$ 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。
| 规格 | 类型 | 描述 |
|---|---|---|
|
|
| 为单节点 OpenShift 集群定义节点的名称。 |
| 规格 | 类型 | 描述 |
|---|---|---|
|
|
| 指定主机的网络配置,例如:
如果需要静态网络,您必须在创建实时安装 ISO 的主机上安装 重要 接口的名称必须与操作系统中显示的实际 NIC 名称匹配。 |
|
|
| 指定所有集群主机的 NTP 源列表。这些 NTP 源会添加到集群中的任何现有 NTP 源中。您可以将主机名或 IP 地址用于 NTP 源。 |
|
|
| 指定用于 seed 集群的发行镜像的容器镜像 registry。 |
|
|
| 为单节点 OpenShift 节点指定自定义节点标签,例如:
|