1.3. 在断开连接的环境中安装
您可能需要在断开连接的 OpenShift Container Platform 集群上安装 Red Hat Advanced Cluster Management。要在断开连接的 hub 集群上安装,除了用于连接网络环境的常规安装或升级步骤外,还执行下列步骤。
需要的访问权限:集群管理员
有关完全支持信息,请参阅 Red Hat Advanced Cluster Management Support Matrix 以及 Red Hat Advanced Cluster Management for Kubernetes 的生命周期和更新策略。
1.3.1. 先决条件 复制链接链接已复制到粘贴板!
在安装 Red Hat Advanced Cluster Management for Kubernetes 前,需要满足以下要求:
- 由于您在断开连接的网络环境中安装,您需要访问本地镜像 registry 以存储镜像 Operator Lifecycle Manager 目录和 Operator 镜像。在此环境中安装 OpenShift Container Platform 集群时,您可能已经设置了一个本地镜像 registry,因此应该可以使用相同的本地镜像 registry。
- 您必须有一个可以访问互联网和您的本地镜像 registry 的工作站。
- 您需要一个受支持的 OpenShift Container Platform 版本,它与环境中部署的 Red Hat Advanced Cluster Management 版本一致。
- 您必须使用命令行界面登录。有关安装 OpenShift Container Platform 的信息,请参阅 OpenShift Container Platform 安装文档。如需有关安装和配置命令行工具的信息,请参阅 CLI 入门。
请参阅调整集群大小以了解如何为您的 hub 集群设置容量。
- 如果您之前在集群中安装 Red Hat Advanced Cluster Management,然后卸载,则需要按照清理步骤删除工件。请参阅在 重新安装前清理工件 并遵循这个流程。
1.3.2. 在断开连接的环境中安装 复制链接链接已复制到粘贴板!
请参阅以下流程,在断开连接的 OpenShift Container Platform 集群上安装 Red Hat Advanced Cluster Management。
在连接时确认 OpenShift Container Platform 安装。验证 Red Hat Advanced Cluster Management hub 集群还没有在 OpenShift Container Platform 集群中安装。每个 OpenShift Container Platform 集群中只能有一个 Red Hat Advanced Cluster Management hub 集群安装。
要确保正确设置 OpenShift Container Platform 集群,请使用以下命令访问 OpenShift Container Platform Web 控制台:
oc -n openshift-console get route
oc -n openshift-console get routeCopy to Clipboard Copied! Toggle word wrap Toggle overflow 请参见以下示例输出:
openshift-console console console-openshift-console.apps.new-coral.purple-chesterfield.com console https reencrypt/Redirect None
openshift-console console console-openshift-console.apps.new-coral.purple-chesterfield.com console https reencrypt/Redirect NoneCopy to Clipboard Copied! Toggle word wrap Toggle overflow 在浏览器中打开 URL 并检查结果。如果控制台 URL 显示
console-openshift-console.router.default.svc.cluster.local,当安装 OpenShift Container Platform 时把openshift_master_default_subdomain设置为这个值。确认本地镜像 registry 的可用性。最佳实践: 将现有的镜像 registry 用于 Operator Lifecycle Manager Operator 相关内容。
在断开连接的环境中安装 Red Hat Advanced Cluster Management 涉及使用本地镜像 registry。因为您已在断开连接的环境中完成 OpenShift Container Platform 集群的安装,所以您已设置了一个镜像 registry,以便在 OpenShift Container Platform 集群安装过程中使用。
如果您还没有本地镜像 registry,请按照完成镜像( mirror)中的内容来创建镜像,以进行 Red Hat OpenShift Container Platform 文档的断开连接的安装。
配置 Operator Lifecycle Manager。Red Hat Advanced Cluster Management 打包为 Operator,因此您可以使用 Operator Lifecycle Manager 安装。
在断开连接的环境中,Operator Lifecycle Manager 无法访问红帽提供的 Operator 的标准 Operator 源,因为它们托管在无法从断开连接的集群访问的镜像 registry 上。集群管理员可以使用镜像 registry 和 Operator 目录在断开连接的环境中启用安装和升级 Operator。
要准备断开连接的集群以安装 Red Hat Advanced Cluster Management,请按照 OpenShift Container Platform 文档中的 受限网络中使用 Operator Lifecycle Manager 中的步骤进行。
在镜像目录中包含 operator 软件包。
红帽在 Red Hat operator 目录中提供了 Red Hat Advanced Cluster Management Operator,它由
registry.redhat.io/redhat/redhat-operator-index索引镜像提供。当您准备此目录索引镜像的镜像时,您可以选择将镜像整个目录作为红帽提供的镜像,或者镜像只包含您要使用的 Operator 软件包的子集。如果您要创建完整镜像目录,则不需要特别考虑安装 Red Hat Advanced Cluster Management 的所有软件包。但是,如果您要创建部分或过滤了镜像目录,您要为其识别要包含的特定软件包,则需要在您的列表中包含以下软件包名称:
-
advanced-cluster-management -
multicluster-engine
-
使用以下两个镜像流程之一:
如果您要使用 OPM 实用程序(
opm index prune)创建镜像的目录或 registry,请在 the-p选项的值中包含以下软件包名称,如下例所示,使用当前版本替换4.x:opm index prune \ -f registry.redhat.io/redhat/redhat-operator-index:v4.x \ -p advanced-cluster-management,multicluster-engine \ -t myregistry.example.com:5000/mirror/my-operator-index:v4.x
opm index prune \ -f registry.redhat.io/redhat/redhat-operator-index:v4.x \ -p advanced-cluster-management,multicluster-engine \ -t myregistry.example.com:5000/mirror/my-operator-index:v4.xCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
如果您使用
oc-mirror插件填充镜像的目录或 registry,请在ImageSetConfiguration的软件包列表部分中包含以下软件包名称,如下例所示,使用当前版本替换4.x:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 配置以使用您的镜像 registry。
当您使用安装 Red Hat Advanced Cluster Management 所需的之前软件包填充本地镜像 registry 时,请完成 在受限网络中使用 Operator Lifecycle Manager 中描述的步骤,使您的镜像 registry 和目录在断开连接的集群中可用,其中包括以下步骤:
-
按照 OpenShift Container Platform 文档在断开连接的集群中添加
CatalogSource资源。重要信息: 请注意metadata.name字段的值,稍后您将需要。 使用类似以下示例的 YAML 文件将
CatalogSource资源添加到openshift-marketplace命名空间中,将4.x替换为当前版本:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在稍后创建的
MultiClusterHub资源中需要注解的metadata.name字段值。验证所需的软件包可用。
Operator Lifecycle Manager 定期轮询可用软件包的目录源。Operator Lifecycle Manager 轮询镜像目录的目录源后,您可以通过查询可用的
PackageManifest资源来验证在断开连接的集群中是否有所需软件包可用。运行以下命令,定向至断开连接的集群:
oc -n openshift-marketplace get packagemanifests
oc -n openshift-marketplace get packagemanifestsCopy to Clipboard Copied! Toggle word wrap Toggle overflow 此时会显示的列表应该包括以下软件包由您的镜像目录的目录源提供:
-
advanced-cluster-management -
multicluster-engine
-
配置镜像内容源策略。
要让集群从您的镜像 registry 获取 Red Hat Advanced Cluster Management for Kubernetes Operator 的容器镜像,而不是从互联网托管的 registry 中配置 ImageContentSourcePolicy,以便在断开连接的环境中配置
ImageContentSourcePolicy,将镜像引用重定向到您的镜像 registry。如果使用
oc adm catalog mirror命令对目录进行镜像,所需的镜像内容源策略配置位于由该命令创建的manifests-*目录的imageContentSourcePolicy.yaml文件中。如果您使用 oc-mirror 插件替代您的目录,则
imageContentSourcePolicy.yaml文件位于oc-mirror-workspace/results-*目录中。使用
oc apply或oc replace将策略应用到断开连接的命令中。使用以下命令:oc replace -f ./<path>/imageContentSourcePolicy.yaml
oc replace -f ./<path>/imageContentSourcePolicy.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow 所需的镜像内容源策略语句会根据您创建镜像 registry 的方式而有所不同,但类似以下示例:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 安装 Red Hat Advanced Cluster Management operator 和 hub 集群。
配置 Operator Lifecycle Manager 和 OpenShift Container Platform 后,您可以使用 Red Hat OpenShift Software Catalog 控制台或命令行界面安装 Red Hat Advanced Cluster Management。有关指示 ,请参阅在线安装。
创建
MulticlusterHub资源是 hub 集群的安装过程开始。因为集群上的 Operator 安装需要为镜像目录使用非默认目录源,所以
MulticlusterHub资源中需要一个特殊的注解来向 Operator 提供镜像目录源的名称。以下示例显示了所需的mce-subscription-spec注解:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 需要
mce-subscription-spec注解,因为 multicluster engine operator 会在 Red Hat Advanced Cluster Management 安装过程中自动安装。如果您要使用 CLI 创建资源,请在使用oc apply命令应用的 YAML 中包含mce-subscription-spec注解来创建MultiClusterHub资源。如果使用控制台创建资源,切换到 YAML 视图 并插入前面显示的注解。重要: OperatorHub 控制台中没有用于注解在 Field 视图 面板中的字段来创建
MultiClusterHub资源。
1.3.3. 目录源优先级 复制链接链接已复制到粘贴板!
当 MultiClusterHub 资源准备安装多集群引擎 operator 时,它会以标准的形式实现 CatalogSource 优先级。
Red Hat Advanced Cluster Management MultiClusterHub 资源查找 CatalogSource,其中包含与当前 Red Hat Advanced Cluster Management 版本兼容的所需多集群引擎 operator 版本。
如果有多个 CatalogSource 资源,MultiClusterHub 资源选择资源实例中设置的最高 spec.priority 值的目录源。
如果在没有优先级级别的情况下创建自定义 CatalogSource,它将被设置为 0, 并用作目标 CatalogSource。
默认情况下,redhat-operators 优先级被设置为-100,如下例所示: