第 2 章 使用 Operator 在 air-gapped 环境中安装 Red Hat Developer Hub
在在受限网络中运行的 OpenShift Container Platform 集群上,无法使用公共资源。但是,部署 Red Hat Developer Hub Operator 并运行 Developer Hub 需要以下公共资源:
- Operator 镜像(bundle, operator, catalog)
- 操作对象镜像(RHDH、PostgreSQL)
要使这些资源可用,请将它们替换为 OpenShift Container Platform 集群可访问的镜像 registry 中的等效资源。
您可以使用一个帮助程序脚本来镜像所需的镜像,并提供必要的配置,以确保在安装 Red Hat Developer Hub Operator 并创建 Developer Hub 实例时将使用这些镜像。
此脚本需要一个目标镜像 registry,如果 OpenShift Container Platform 集群准备好在受限网络中操作,则应该已安装该 registry。但是,如果您准备集群以断开连接使用,您可以使用脚本在集群中部署镜像 registry,并将其用于镜像过程。
先决条件
-
您有一个活跃的 OpenShift CLI (
oc)会话,其中包含对 OpenShift Container Platform 集群的管理权限。请参阅 OpenShift CLI 入门。 -
您有一个活跃的
oc registry会话到registry.redhat.io红帽生态系统目录。请参阅 Red Hat Container Registry Authentication。 -
已安装
opmCLI 工具。请参阅安装 opm CLI。 - 已安装 jq 软件包。请参阅 下载 jq。
- podman 已安装。请参阅 Podman 安装说明。
- Skopeo 版本 1.14 或更高版本已安装。请参阅 安装 Skopeo。
- 如果您已经有集群的镜像 registry,则需要一个具有管理访问权限的活跃 Skopeo 会话。请参阅认证到 registry 并为断开连接的安装 mirror 镜像。
内部 OpenShift Container Platform 集群镜像 registry 不能用作目标镜像 registry。请参阅关于镜像 registry。
- 如果要创建自己的镜像 registry,请参阅为 Red Hat OpenShift 创建带有 mirror registry 的 mirror registry。
如果您还没有镜像 registry,您可以使用 helper 脚本为您创建一个,并需要以下额外先决条件:
- 已安装 cURL 软件包。对于 Red Hat Enterprise Linux,可以通过安装 curl 软件包来使用 curl 命令。要将 curl 用于其他平台,请查看 cURL 网站。
-
htpasswd命令可用。对于 Red Hat Enterprise Linux,可以通过安装httpd-tools软件包来使用htpasswd命令。
流程
下载并运行镜像脚本,以安装自定义 Operator 目录并镜像相关镜像:
prepare-restricted-environment.sh(source)。curl -sSLO https://raw.githubusercontent.com/redhat-developer/rhdh-operator/release-1.3/.rhdh/scripts/prepare-restricted-environment.sh # if you do not already have a target mirror registry # and want the script to create one for you # use the following example: bash prepare-restricted-environment.sh \ --prod_operator_index "registry.redhat.io/redhat/redhat-operator-index:v4.17" \ --prod_operator_package_name "rhdh" \ --prod_operator_bundle_name "rhdh-operator" \ --prod_operator_version "v1.3.5" # if you already have a target mirror registry # use the following example: bash prepare-restricted-environment.sh \ --prod_operator_index "registry.redhat.io/redhat/redhat-operator-index:v4.17" \ --prod_operator_package_name "rhdh" \ --prod_operator_bundle_name "rhdh-operator" \ --prod_operator_version "v1.3.5" \ --use_existing_mirror_registry "my_registry"注意该脚本可能需要几分钟才能完成,因为它将多个镜像复制到镜像 registry。