在单一节点上安装
在单一节点上安装 OpenShift Container Platform
摘要
第 1 章 准备在一个节点上安装
1.1. 先决条件
- 您可以参阅有关 OpenShift Container Platform 安装和更新 流程的详细信息。
- 您已阅读了有关 选择集群安装方法并为用户准备它 的文档。
1.2. 关于单个节点上的 OpenShift
您可以使用标准安装方法创建单节点集群。单一节点上的 OpenShift Container Platform 是一个特殊安装,需要创建特殊的 ignition 配置 ISO。它的主要用例是用于边缘计算工作负载,包括相邻连接、便携式云和靠近基站的 5G 无线访问网络(RAN)。在单一节点上安装时的主要权衡在于缺乏高可用性。
不支持将 OpenShiftSDN 与单节点 OpenShift 搭配使用。OVN-Kubernetes 是单节点 OpenShift 部署的默认网络插件。
1.3. 在单一节点上安装 OpenShift 的要求
在单一节点上安装 OpenShift Container Platform 可降低高可用性和大型集群的一些要求。但是,您必须满足以下要求:
- 管理主机: 您必须有一台计算机来准备 ISO、创建 USB 引导驱动器以及监控安装。
-
CPU 架构: 在单一节点上安装 OpenShift Container Platform 支持
x86_64
和arm64
CPU 架构。 支持的平台: 在裸机和经认证的第三方虚拟机监控程序上支持在单一节点上安装 OpenShift Container Platform。在大多数情况下,您必须在
install-config.yaml
配置文件中指定platform.none: {}
参数。以下列表显示了install-config.yaml
配置文件中指定的唯一例外和对应的参数:-
Amazon Web Services (AWS),您在其中使用
platform=aws
-
Google Cloud Platform (GCP),您在其中使用
platform=gcp
-
Microsoft Azure,您在其中使用
platform=azure
-
Amazon Web Services (AWS),您在其中使用
production -grade server: 在单一节点上安装 OpenShift Container Platform 需要具有足够资源的服务器来运行 OpenShift Container Platform 服务和生产工作负载。
表 1.1. 最低资源要求 profile vCPU memory Storage 最小值
8 个 vCPU
16GB RAM
120GB
注意一个 vCPU 等于一个物理内核。但是,如果您启用并发多线程(SMT)或超线程,请使用以下公式来计算代表一个物理内核的 vCPU 数量:
- (每个内核的线程数 x 内核数)x 插槽数 = vCPU
- 在安装过程中添加 Operator 可能会增加最低资源要求。
使用虚拟介质引导时,服务器必须具有基板管理控制器(BMC)。
网络: 如果服务器没有连接到可路由的网络,则服务器必须可以访问互联网或访问本地注册表。服务器必须具有 Kubernetes API、Ingress 路由和集群节点域名的 DHCP 保留或静态 IP 地址。您必须配置 DNS,以将 IP 地址解析为以下完全限定域名(FQDN):
表 1.2. 所需的 DNS 记录 用法 FQDN 描述 Kubernetes API
api.<cluster_name>.<base_domain>
添加 DNS A/AAAA 或 CNAME 记录。此记录必须由集群外的客户端和集群内解析。
内部 API
api-int.<cluster_name>.<base_domain>
在手动创建 ISO 时,添加 DNS A/AAAA 或 CNAME 记录。此记录必须由集群内的节点解析。
Ingress 路由
*.apps.<cluster_name>.<base_domain>
添加以节点为目标的通配符 DNS A/AAAA 或 CNAME 记录。此记录必须由集群外的客户端和集群内解析。
重要如果没有持久的 IP 地址,
apiserver
和etcd
之间的通信可能会失败。
第 2 章 在单一节点上安装 OpenShift
您可以使用基于 Web 的 Assisted Installer 或 coreos-installer
工具安装单节点 OpenShift 来生成发现 ISO 镜像。发现 ISO 镜像将 Red Hat Enterprise Linux CoreOS (RHCOS)系统配置写入目标安装磁盘,以便您可以运行单集群节点来满足您的需求。
在低资源或隔离环境中运行集群时,请考虑使用单节点 OpenShift 进行测试、故障排除、培训或小型项目目的。
2.1. 使用 Assisted Installer 安装单节点 OpenShift
要在单一节点上安装 OpenShift Container Platform,请使用基于 web 的 Assisted Installer 向导来引导您完成安装过程并管理安装。
2.1.1. 使用 Assisted Installer 生成发现 ISO
在单一节点上安装 OpenShift Container Platform 需要发现 ISO,辅助安装程序可生成。
流程
- 在管理主机上,打开浏览器并进入到 Red Hat OpenShift Cluster Manager。
- 单击 Create New Cluster 以创建新集群。
- 在 Cluster name 字段中输入集群名称。
在 Base domain 字段中,输入基域。例如:
example.com
所有 DNS 记录都必须是这个基域的子域并包含集群名称,例如:
<cluster_name>.example.com
注意您不能在集群安装后更改基域或集群名称。
- 选择 Install single node OpenShift (SNO) 并完成向导步骤的其余部分。下载发现 ISO。
完成剩余的 Assisted Installer 向导步骤。
重要确保您记下用于使用虚拟介质安装的发现 ISO URL。
如果在此过程中启用 OpenShift Virtualization,则必须为虚拟机有第二个至少 50GiB 的本地存储设备。
2.1.2. 使用 Assisted Installer 安装单节点 OpenShift
使用辅助安装程序安装单节点集群。
先决条件
- 确保服务器 BIOS 设置中的引导驱动器顺序默认为从目标安装磁盘引导服务器。
流程
- 将发现 ISO 镜像附加到目标主机。
- 从发现 ISO 镜像引导服务器。发现 ISO 镜像将系统配置写入目标安装磁盘,并自动触发服务器重启。
- 在管理主机上,返回到浏览器。等待主机出现在已发现的主机列表中。如有必要,重新载入 Assisted Clusters 页面并选择集群名称。
- 完成安装向导步骤。添加网络详情,包括可用子网中的子网。如果需要,添加 SSH 公钥。
- 监控安装的进度。观察集群出现的事件。在安装过程完成后,将操作系统镜像写入服务器的硬盘中,服务器会重启。
可选:删除发现 ISO 镜像。
服务器自动重启了多次,部署 control plane。
2.2. 手动安装单节点 OpenShift
要在单一节点上安装 OpenShift Container Platform,首先生成安装 ISO,然后从 ISO 引导服务器。您可以使用 openshift-install
安装程序监控安装。
2.2.1. 使用 coreos-installer 生成安装 ISO
在单一节点上安装 OpenShift Container Platform 需要安装 ISO,您可以按照以下流程生成该 ISO。
先决条件
-
安装
podman
。
如需了解网络要求,请参阅"在单一节点上安装 OpenShift 的要求,包括 DNS 记录。
流程
设置 OpenShift Container Platform 版本:
$ export OCP_VERSION=<ocp_version> 1
- 1
- 将
<ocp_version>
替换为当前版本,如latest-4.13
设置主机架构:
$ export ARCH=<architecture> 1
- 1
- 将
<architecture>
替换为目标主机架构,如aarch64
或x86_64
。
输入以下命令下载 OpenShift Container Platform 客户端(
oc
)并使其可用:$ curl -k https://mirror.openshift.com/pub/openshift-v4/clients/ocp/$OCP_VERSION/openshift-client-linux.tar.gz -o oc.tar.gz
$ tar zxf oc.tar.gz
$ chmod +x oc
输入以下命令下载 OpenShift Container Platform 安装程序并使其可用:
$ curl -k https://mirror.openshift.com/pub/openshift-v4/clients/ocp/$OCP_VERSION/openshift-install-linux.tar.gz -o openshift-install-linux.tar.gz
$ tar zxvf openshift-install-linux.tar.gz
$ chmod +x openshift-install
运行以下命令来检索 RHCOS ISO URL:
$ export ISO_URL=$(./openshift-install coreos print-stream-json | grep location | grep $ARCH | grep iso | cut -d\" -f4)
下载 RHCOS ISO:
$ curl -L $ISO_URL -o rhcos-live.iso
准备
install-config.yaml
文件:apiVersion: v1 baseDomain: <domain> 1 compute: - name: worker replicas: 0 2 controlPlane: name: master replicas: 1 3 metadata: name: <name> 4 networking: 5 clusterNetwork: - cidr: 10.128.0.0/14 hostPrefix: 23 machineNetwork: - cidr: 10.0.0.0/16 6 networkType: OVNKubernetes serviceNetwork: - 172.30.0.0/16 platform: none: {} bootstrapInPlace: installationDisk: /dev/disk/by-id/<disk_id> 7 pullSecret: '<pull_secret>' 8 sshKey: | <ssh_key> 9
- 1
- 添加集群域名。
- 2
- 将
计算
副本设置为0
。这使得 control plane 节点可以调度。 - 3
- 将
controlPlane
副本设置为1
。与前面的compute
设置结合使用,此设置可确保集群在单一节点上运行。 - 4
- 将
metadata
名称设置为集群名称。 - 5
- 设置
网络
详情。OVN-Kubernetes 是单节点集群唯一支持的网络插件类型。 - 6
- 将
cidr
值设置为与单节点 OpenShift 集群的子网匹配。 - 7
- 设置安装磁盘驱动器的路径,例如:
/dev/disk/by-id/wwn-0x64cd98f04fde100024684cf3034da5c2
。 - 8
- 复制来自 Red Hat OpenShift Cluster Manager 的 pull secret,并将内容添加到此配置设置中。
- 9
- 从管理主机添加公共 SSH 密钥,以便您可以在安装后登录集群。
运行以下命令来生成 OpenShift Container Platform 资产:
$ mkdir ocp
$ cp install-config.yaml ocp
$ ./openshift-install --dir=ocp create single-node-ignition-config
运行以下命令,将 ignition 数据嵌入到 RHCOS ISO 中:
$ alias coreos-installer='podman run --privileged --pull always --rm \ -v /dev:/dev -v /run/udev:/run/udev -v $PWD:/data \ -w /data quay.io/coreos/coreos-installer:release'
$ coreos-installer iso ignition embed -fi ocp/bootstrap-in-place-for-live-iso.ign rhcos-live.iso
其他资源
- 如需有关在单一节点上安装 OpenShift Container Platform 的更多信息,请参阅在单一节点上安装 OpenShift 的要求。
- 如需有关启用安装前禁用的集群功能的更多信息,请参阅启用集群功能。
- 如需有关 每个功能提供的功能的更多信息,请参阅 OpenShift Container Platform 4.13 中的可选集群功能。
2.2.2. 使用 openshift-install 监控集群安装
使用 openshift-install
监控单节点集群安装的进度。
先决条件
- 确保服务器 BIOS 设置中的引导驱动器顺序默认为从目标安装磁盘引导服务器。
流程
- 将发现 ISO 镜像附加到目标主机。
- 从发现 ISO 镜像引导服务器。发现 ISO 镜像将系统配置写入目标安装磁盘,并自动触发服务器重启。
在管理主机上,运行以下命令来监控安装:
$ ./openshift-install --dir=ocp wait-for install-complete
在部署 control plane 时服务器重启几次。
验证
安装完成后,运行以下命令来检查环境:
$ export KUBECONFIG=ocp/auth/kubeconfig
$ oc get nodes
输出示例
NAME STATUS ROLES AGE VERSION control-plane.example.com Ready master,worker 10m v1.26.0
2.3. 在 AWS 上安装单节点 OpenShift
2.3.1. 在 AWS 上的单一节点上安装的额外要求
安装程序置备的安装的 AWS 文档使用由三个 control plane 节点组成的高可用性集群编写。在引用 AWS 文档时,请考虑单节点 OpenShift 集群的要求与高可用性集群之间的区别。
- AWS 文档中的集群安装所需的机器表示临时 bootstrap 机器、三台 control plane 机器和至少两台计算机器。您只需要一个临时 bootstrap 机器和一个 AWS 实例用于 control plane 节点,且没有 worker 节点。
- AWS 文档中的集群安装的最低资源要求表示 control plane 节点有 4 个 vCPU 和 100GB 存储。对于单一节点集群,必须至少有 8 个 vCPU 内核和 120GB 存储。
-
install-config.yaml
文件中的controlPlane.replicas
设置应设置为1
。 -
install-config.yaml
文件中的compute.replicas
设置应设置为0
。这使得 control plane 节点可以调度。
2.3.2. 在 AWS 上安装单节点 OpenShift
在 AWS 上安装单一节点集群需要使用"在带有自定义"流程的 AWS 上安装集群。
其他资源
2.4. 在 USB 驱动器中创建可引导 ISO 镜像
您可以使用包含 ISO 镜像的可引导 USB 驱动器安装软件。使用 USB 驱动器引导服务器为软件安装准备服务器。
流程
- 在管理主机上,在 USB 端口中插入 USB 驱动器。
创建可引导 USB 驱动器,例如:
# dd if=<path_to_iso> of=<path_to_usb> status=progress
其中:
- <path_to_iso>
-
是下载的 ISO 文件的相对路径,例如
rhcos-live.iso
。 - <path_to_usb>
-
是连接的 USB 驱动器的位置,例如
/dev/sdb
。
将 ISO 复制到 USB 驱动器后,您可以使用 USB 驱动器在服务器上安装软件。
2.5. 使用 Redfish API 从 HTTP 托管 ISO 镜像引导
您可以使用 Redfish Baseboard Management Controller (BMC) API 安装的 ISO 来置备网络中的主机。
这个示例步骤演示了在 Dell 服务器上进行的步骤。
确保具有与硬件兼容的 iDRAC 的最新固件版本。如果硬件或固件有问题,您必须联系相关供应商。
先决条件
- 下载安装 Red Hat Enterprise Linux CoreOS (RHCOS) ISO。
- 使用与 iDRAC9 兼容的 Dell PowerEdge 服务器。
流程
- 将 ISO 文件复制到网络中的 HTTP 服务器。
从托管 ISO 文件引导主机,例如:
运行以下命令,调用 Redfish API 将托管的 ISO 设置为
VirtualMedia
引导介质:$ curl -k -u <bmc_username>:<bmc_password> -d '{"Image":"<hosted_iso_file>", "Inserted": true}' -H "Content-Type: application/json" -X POST <host_bmc_address>/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.InsertMedia
其中:
- <bmc_username>:<bmc_password>
- 是目标主机 BMC 的用户名和密码。
- <hosted_iso_file>
-
是托管安装 ISO 的 URL,例如:
http://webserver.example.com/rhcos-live-minimal.iso
。ISO 必须从目标主机机器中访问。 - <host_bmc_address>
- 是目标主机计算机的 BMC IP 地址。
运行以下命令,将主机设置为从
VirtualMedia
设备引导:$ curl -k -u <bmc_username>:<bmc_password> -X PATCH -H 'Content-Type: application/json' -d '{"Boot": {"BootSourceOverrideTarget": "Cd", "BootSourceOverrideMode": "UEFI", "BootSourceOverrideEnabled": "Once"}}' <host_bmc_address>/redfish/v1/Systems/System.Embedded.1
重启主机:
$ curl -k -u <bmc_username>:<bmc_password> -d '{"ResetType": "ForceRestart"}' -H 'Content-type: application/json' -X POST <host_bmc_address>/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset
可选: 如果主机已关闭,您可以使用
{"ResetType": "On"}
开关引导它。运行以下命令:$ curl -k -u <bmc_username>:<bmc_password> -d '{"ResetType": "On"}' -H 'Content-type: application/json' -X POST <host_bmc_address>/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset
2.6. 为远程服务器访问创建自定义 live RHCOS ISO
在某些情况下,您无法将外部磁盘驱动器附加到服务器,但您需要远程访问服务器来调配节点。建议您启用对服务器的 SSH 访问。您可以创建一个启用了 SSHd 并预定义的凭证的 live RHCOS ISO,以便您可以在服务器引导后访问服务器。
先决条件
-
已安装
butane
工具。
流程
-
从
coreos-installer
image mirror 页面下载coreos-installer
二进制文件。 - 从 mirror.openshift.com 下载最新的 live RHCOS ISO。
创建
butane
实用程序用来创建 Ignition 文件的embedded.yaml
文件:variant: openshift version: 4.13.0 metadata: name: sshd labels: machineconfiguration.openshift.io/role: worker passwd: users: - name: core 1 ssh_authorized_keys: - '<ssh_key>'
- 1
core
用户具有 sudo 权限。
运行以下命令,运行
butane
工具来创建 Ignition 文件:$ butane -pr embedded.yaml -o embedded.ign
创建 Ignition 文件后,您可以使用
coreos-installer
工具将配置包含在新的 live RHCOS ISO 中,名为rhcos-sshd-4.13.0-x86_64-live.x86_64.iso
:$ coreos-installer iso ignition embed -i embedded.ign rhcos-4.13.0-x86_64-live.x86_64.iso -o rhcos-sshd-4.13.0-x86_64-live.x86_64.iso
验证
运行以下命令,检查自定义 live ISO 是否可用于引导服务器:
# coreos-installer iso ignition show rhcos-sshd-4.13.0-x86_64-live.x86_64.iso
输出示例
{ "ignition": { "version": "3.2.0" }, "passwd": { "users": [ { "name": "core", "sshAuthorizedKeys": [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCZnG8AIzlDAhpyENpK2qKiTT8EbRWOrz7NXjRzopbPu215mocaJgjjwJjh1cYhgPhpAp6M/ttTk7I4OI7g4588Apx4bwJep6oWTU35LkY8ZxkGVPAJL8kVlTdKQviDv3XX12l4QfnDom4tm4gVbRH0gNT1wzhnLP+LKYm2Ohr9D7p9NBnAdro6k++XWgkDeijLRUTwdEyWunIdW1f8G0Mg8Y1Xzr13BUo3+8aey7HLKJMDtobkz/C8ESYA/f7HJc5FxF0XbapWWovSSDJrr9OmlL9f4TfE+cQk3s+eoKiz2bgNPRgEEwihVbGsCN4grA+RzLCAOpec+2dTJrQvFqsD alosadag@sonnelicht.local" ] } ] } }
Legal Notice
Copyright © 2024 Red Hat, Inc.
OpenShift documentation is licensed under the Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0).
Modified versions must remove all Red Hat trademarks.
Portions adapted from https://github.com/kubernetes-incubator/service-catalog/ with modifications by Red Hat.
Red Hat, Red Hat Enterprise Linux, the Red Hat logo, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation’s permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.