1.4. 在断开连接的网络中安装

您可能需要在未连接到互联网的 Red Hat OpenShift Container Platform 集群中安装 Red Hat Advanced Cluster Management for Kubernetes。在断开连接的 hub 中安装的步骤包括一些在连接环境中进行安装的步骤。

您必须下载软件包副本以在安装过程中访问它们,而不是在安装过程中直接从网络访问它们。

在开始前,请查看 要求和建议 部分,然后参阅以下文档:

1.4.1. 先决条件

在安装 Red Hat Advanced Cluster Management for Kubernetes 前,需要满足以下要求:

  • Red Hat OpenShift Container Platform 版本 4.8 或更高版本必须部署到您的环境中,且必须使用 CLI 登录。
  • 您需要访问 catalog.redhat.com

    注: 要管理裸机集群,您必须使用 OpenShift Container Platform 版本 4.8 或更高版本。

    请参阅 OpenShift Container Platform 版本 4.10OpenShift Container Platform 版本 4.10

  • 您的 Red Hat OpenShift Container Platform CLI 需要版本 4.8 或更高版本,并配置为运行 oc 命令。如需有关安装和配置 Red Hat OpenShift CLI 的信息,请参阅 CLI 入门
  • 您的 Red Hat OpenShift Container Platform 权限必须允许创建命名空间。安装在没有命名空间的情况下会失败。
  • 必须有一 个有互联网连接的工作站来下载 operator 的依赖软件包。

1.4.2. 确认 OpenShift Container Platform 安装

  • 您必须有一个受支持的 OpenShift Container Platform 版本,包括 registry 和存储服务,在集群中安装并正常工作。如需有关 OpenShift Container Platform 版本 4.10 的更多信息,请参阅 OpenShift Container Platform 文档
  • 连接后,运行 kubectl -n openshift-console get route 命令来访问 OpenShift Container Platform Web 控制台。请参见以下示例输出:

    openshift-console          console             console-openshift-console.apps.new-coral.purple-chesterfield.com                       console              https   reencrypt/Redirect     None

    本例中的控制台 URL 为 https:// console-openshift-console.apps.new-coral.purple-chesterfield.com。在浏览器中打开 URL 并检查结果。

    如果控制台 URL 显示 console-openshift-console.router.default.svc.cluster.local,当安装 OpenShift Container Platform 时把 openshift_master_default_subdomain 设置为这个值。

请参阅计划集群大小,以了解如何为您的 hub 集群设置容量。

1.4.3. 在断开连接的环境中安装

重要: 您需要将所需的镜像下载到镜像 registry 中,以便在断开连接的环境中安装 Operator。如果没有下载,您可能会在部署过程中收到 ImagePullBackOff 错误。

按照以下步骤在断开连接的环境中安装 Red Hat Advanced Cluster Management:

  1. 创建镜像 registry。如果您还没有镜像 registry,请按照 Red Hat OpenShift Container Platform 文档中的为断开连接的环境创建镜像的容器镜像的步骤来创建。

    如果已有镜像 registry,可以配置和使用现有 registry。

    注: 确保按照 OpenShift Container Platform 文档中的从镜像 Operator 目录中提取 OperatorHub 的步骤。

  2. 镜像 operator 目录。按照 Mirroring Operator catalogs for use with disconnected clusters 中的步骤对 operator 进行了镜像。

备注:

  • 如果您要从现有 Red Hat Operator 索引镜像中修剪软件包,请确保修剪 advanced-cluster-managementmulticluster-engine 软件包。如需更多信息,请参阅过滤基于 SQLite 的索引镜像
  • 生成清单过程中,您将在清单目录中生成 catalogSource.yaml 文件。在配置断开连接的 Operator Lifecycle Manager 时,您将使用此示例文件。
  • 对于裸机,您需要在 install-config.yaml 文件中为断开连接的 registry 提供证书信息。要访问受保护的断开连接的 registry 中的镜像,必须提供证书信息,以便 Red Hat Advanced Cluster Management 可以访问 registry。

    1. 复制 registry 中的证书信息。
    2. 在编辑器中打开 install-config.yaml 文件。
    3. 找到 additionalTrustBundle: | 条目。
    4. additionalTrustBundle 行后添加证书信息。内容结果类似以下示例:

      additionalTrustBundle: |
        -----BEGIN CERTIFICATE-----
        certificate_content
        -----END CERTIFICATE-----
      sshKey: >-

      重要: 如果需要以下监管策略,则需要额外的镜像 registry:

      • 容器安全 operator 策略:镜像位于源 registry.redhat.io/quay
      • Compliance operator 策略:镜像位于源 registry.redhat.io/compliance 中。
      • Gatekeeper operator 策略:镜像位于源 registry.redhat.io/rhacm2 中。

        参阅以下所有三个 operator 的镜像列表示例:

            - mirrors:
              - <your_registry>/rhacm2
              source: registry.redhat.io/rhacm2
            - mirrors:
              - <your_registry>/quay
              source: registry.redhat.io/quay
            - mirrors:
              - <your_registry>/compliance
              source: registry.redhat.io/compliance
        1. 保存 install-config.yaml 文件。
        2. 创建一个包含 ImageContentSourcePolicy 的 YAML 文件,其名称为 rhacm-policy.yaml注: 如果您在正在运行的集群中修改此操作,则会导致所有节点的滚动重启。

          apiVersion: operator.openshift.io/v1alpha1
          kind: ImageContentSourcePolicy
          metadata:
            name: rhacm-repo
          spec:
            repositoryDigestMirrors:
            - mirrors:
              - mirror.registry.com:5000/rhacm2
              source: registry.redhat.io/rhacm2
        3. 输入以下命令应用 ImageContentSourcePolicy 文件:

          oc apply -f rhacm-policy.yaml
        4. 启用断开连接的 Operator Lifecycle Manager Red Hat Operator 和 Community Operator。Red Hat Advanced Cluster Management 包括在 Operator Lifecycle Manager Red Hat Operator 目录中。
        5. 为 Red Hat Operator 目录配置离线 Operator Lifecycle Manager。按照 Red Hat OpenShift Container Platform 文档中 受限网络部分中使用 Operator Lifecycle Manager 中的步骤操作。

          • 对于将目录源添加到集群步骤,请使用镜像 Operator 目录时创建的 catalogSource.yaml 文件。
          • 如果您使用自己的 catalogSource.yaml 文件,且目录源名称与预期的 redhat-operator-index 不同,则需要将以下注解添加到 MultiClusterHub 自定义资源中以 my-operator-catalog 代替。
    apiVersion: operator.open-cluster-management.io/v1
    kind: MultiClusterHub
    metadata:
      annotations:
        installer.open-cluster-management.io/mce-subscription-spec: '{"source": "my-operator-catalog"}'

现在,您在断开连接的 Operator Lifecycle Manager 中已有镜像,请从 Operator Lifecycle Manager 目录继续安装 Red Hat Advanced Cluster Management for Kubernetes。

如需了解所需步骤,请参阅在线安装,或返回到安装概述。