第 3 章 使用 Helm Chart 在 air-gapped 环境中的 OpenShift Container Platform 上安装 Red Hat Developer Hub
您可以使用 Red Hat Developer Hub Helm Chart 在完全断开连接或部分断开连接的环境中安装 Red Hat Developer Hub。
3.1. 在使用 Helm Chart 完全断开连接的环境中在 OpenShift Container Platform 上安装 Red Hat Developer Hub
如果您的网络可以通过堡垒主机访问 registry,您可以通过 Helm chart 将指定资源镜像到磁盘来安装 Red Hat Developer Hub,并将其传送到 air-gapped 环境,而无需连接到互联网。
先决条件
您已设置了工作站。
- 您可以访问 registry.redhat.io。
- 您可以访问 charts.openshift.io Helm Chart 仓库。
-
已在工作站上安装了 OpenShift CLI (
oc
)。 -
已安装了 oc-mirror OpenShift CLI (
oc
)插件。如需更多信息,请参阅安装 oc-mirror OpenShift CLI 插件。 - 在 Red Hat Developer Portal 中有一个帐户。
您已设置了您的中间主机。
- 您的主机可以访问断开连接的集群,以及目标镜像 registry,如 Red Hat OpenShift Container Platform 镜像 registry。有关公开 OpenShift Container Platform 镜像 registry 的更多信息,请参阅 公开 registry。
-
已安装了 oc-mirror OpenShift CLI (
oc
)插件。如需更多信息,请参阅安装 oc-mirror OpenShift CLI 插件。 - 已安装 Red Hat OpenShift Container Platform 4.14 或更高版本。
-
已在工作站上安装了 OpenShift CLI (
oc
)。
流程
创建
ImageSetConfiguration
文件,以指定您要镜像的资源。例如:apiVersion: mirror.openshift.io/v1alpha2 kind: ImageSetConfiguration mirror: helm: repositories: - name: <repository_name> (1) url: <repository_url> (2) charts: - name: <chart_name> (3) version: "<rhdh_version>" (4)
apiVersion: mirror.openshift.io/v1alpha2 kind: ImageSetConfiguration mirror: helm: repositories: - name: <repository_name> (1) url: <repository_url> (2) charts: - name: <chart_name> (3) version: "<rhdh_version>" (4)
Copy to Clipboard Copied! - 要镜像的存储库的名称,如
openshift-charts
。 - 要镜像的存储库的 URL,例如
https://charts.openshift.io
。 - 要镜像的 Helm Chart 的名称,如
redhat-developer-hub
。 - 要使用的 Red Hat Developer Hub 版本,如
1.6
运行
oc-mirror
命令,对ImageSetConfiguration.yaml
文件中指定的资源进行镜像(mirror)。例如:oc-mirror --config=<mirror_config_directory>/ImageSetConfiguration.yaml <mirror_archive_directory>/
oc-mirror --config=<mirror_config_directory>/ImageSetConfiguration.yaml <mirror_archive_directory>/
Copy to Clipboard Copied! 其中:
<mirror_config_directory>
-
指定系统上镜像设置配置文件的位置,如
.user
。 <mirror_configuration_file>
-
指定镜像配置 yaml 文件的名称,如
mirror-config.yaml
<mirror_archive_directory>
-
指定创建镜像存档的目录位置,如
file://.user
。
注意运行
oc-mirror
命令会生成一个本地工作区,其中包含镜像归档文件、Helm Chart 和ImageContentSourcePolicy
(ICSP)清单。ICSP 清单包含一个imageContentSourcePolicy.yaml
文件,您必须在以后的步骤中对集群应用该文件。输出示例
Creating archive /path/to/mirror-archive/mirror_seq1_000000.tar
Creating archive /path/to/mirror-archive/mirror_seq1_000000.tar
Copy to Clipboard Copied! -
将生成的存档文件(例如,
mirror_seq1_000000.tar
)传送到 air-gapped 环境。 连接到您的 air-gapped 环境,并确保您也连接到以下对象:
- 本地目标 registry
- 目标 OpenShift Container Platform 集群
在 air-gapped 环境中,通过运行
oc-mirror
命令将资源从存档镜像到目标 registry。例如:oc-mirror --from <mirror-archive-file> <target-registry>
oc-mirror --from <mirror-archive-file> <target-registry>
Copy to Clipboard Copied! 其中:
<mirror_archive_file>
-
指定包含您要镜像资源的文件名称,如
mirror_seq1_0000.tar
。 <target_registry>
-
指定要将镜像推送到的目标 registry 的名称,如
docker://registry.localhost:5000
。
输出示例
Wrote release signatures to oc-mirror-workspace/results-1738075410 Writing image mapping to oc-mirror-workspace/results-1738075410/mapping.txt Writing ICSP manifests to oc-mirror-workspace/results-1738075410
Wrote release signatures to oc-mirror-workspace/results-1738075410 Writing image mapping to oc-mirror-workspace/results-1738075410/mapping.txt Writing ICSP manifests to oc-mirror-workspace/results-1738075410
Copy to Clipboard Copied! 在工作区中,通过运行
ls
命令找到imageContentSourcePolicy.yaml
文件。例如:ls <workspace_directory>/<results_directory>
ls <workspace_directory>/<results_directory>
Copy to Clipboard Copied! 其中:
<workspace_directory>
-
指定工作区目录的名称,如
oc-mirror-workspace
。 <results_directory>
-
指定结果目录的名称,例如
results-1738070846
。
要镜像 Helm Chart,请通过运行
oc apply
命令在断开连接的集群中部署imageContentSourcePolicy.yaml
文件。例如:oc apply -f <workspace_directory>/<results_directory>/ImageContentSourcePolicy.yaml
oc apply -f <workspace_directory>/<results_directory>/ImageContentSourcePolicy.yaml
Copy to Clipboard Copied! 其中:
<workspace-directory>
-
指定工作区目录的名称,如
oc-mirror-workspace
。 <results-directory>
-
指定结果目录的名称,例如
results-1738070846
。
在 air-gapped 环境中,通过运行带有
namespace
和set
选项的helm install
命令,将 Helm Chart 部署到您要使用的命名空间中。例如:CLUSTER_ROUTER_BASE=$(oc get route console -n openshift-console -o=jsonpath='{.spec.host}' | sed 's/[.]*\.//') helm install <rhdh_instance> <workspace_directory>/<results_directory>/charts/<archive_file> --namespace <your_namespace> --create-namespace \ --set global.clusterRouterBase="$CLUSTER_ROUTER_BASE"
CLUSTER_ROUTER_BASE=$(oc get route console -n openshift-console -o=jsonpath='{.spec.host}' | sed 's/[.]*\.//') helm install <rhdh_instance> <workspace_directory>/<results_directory>/charts/<archive_file> --namespace <your_namespace> --create-namespace \ --set global.clusterRouterBase="$CLUSTER_ROUTER_BASE"
Copy to Clipboard Copied! 其中:
<rhdh_instance>
-
指定 Red Hat Developer Hub 实例的名称,如
my-rhdh
。 <workspace_directory>
-
指定工作区目录的名称,如
oc-mirror-workspace
。 <results_directory>
-
指定结果目录的名称,例如
results-1738070846
。 <archive_file>
-
指定包含您要镜像资源的归档文件的名称,如
redhat-developer-hub-1.4.1.tgz
。 <your_namespace>
-
指定要将 Helm Chart 部署到的命名空间,如
my-rhdh-project
。