搜索

2.8. 使用 ArgoCD 配置 hub 集群

download PDF

您可以使用一组 ArgoCD 应用程序来配置 hub 集群,每个站点使用 GitOps 零接触置备 (ZTP) 生成所需的安装和策略自定义资源(CR)。

注意

Red Hat Advanced Cluster Management (RHACM) 使用 SiteConfig CR 为 ArgoCD 生成第 1 天受管集群安装 CR。每个 ArgoCD 应用程序都可以管理最多 300 个 SiteConfig CR。

先决条件

  • 已安装 Red Hat Advanced Cluster Management (RHACM) 和 Red Hat OpenShift GitOps 的 OpenShift Container Platform hub 集群。
  • 您已从 GitOps ZTP 插件容器中提取了引用部署,如 "Preparing the GitOps ZTP site configuration repository" 部分所述。提取引用部署会创建以下流程中引用的 out/argocd/deployment 目录。

流程

  1. 准备 ArgoCD 管道配置:

    1. 创建 Git 存储库,其目录结构类似于 example 目录。如需更多信息,请参阅"准备 GitOps ZTP 站点配置存储库"。
    2. 使用 ArgoCD UI 配置对存储库的访问。在 Settings 下配置以下内容:

      • Repositories - 添加连接信息。URL 必须以 .git 结尾,例如 https://repo.example.com/repo.git 和凭证。
      • 证书 - 如果需要,为存储库添加公共证书。
    3. 根据您的 Git 仓库修改两个 ArgoCD 应用程序, out/argocd/deployment/clusters-app.yamlout/argocd/deployment/policies-app.yaml

      • 更新 URL 以指向 Git 存储库。URL 以 .git 结尾,例如 https://repo.example.com/repo.git
      • targetRevision 表示要监控的 Git 存储库分支。
      • path 指定到 SiteConfigPolicyGenTemplate CR 的路径。
  1. 要安装 GitOps ZTP 插件,使用相关多集群引擎 (MCE) 订阅镜像对 hub 集群中的 ArgoCD 实例进行补丁。自定义您解压到环境的 out/argocd/deployment/ 目录中的补丁文件。

    1. 选择与您的 RHACM 版本匹配的 multicluster-operators-subscription 镜像。

      表 2.5. multicluster-operators-subscription 镜像版本
      OpenShift Container Platform 版本RHACM 版本MCE 版本MCE RHEL 版本MCE 镜像

      4.14, 4.15, 4.16

      2.8, 2.9

      2.8, 2.9

      RHEL 8

      registry.redhat.io/rhacm2/multicluster-operators-subscription-rhel8:v2.8

      registry.redhat.io/rhacm2/multicluster-operators-subscription-rhel8:v2.9

      4.14, 4.15, 4.16

      2.10

      2.10

      RHEL 9

      registry.redhat.io/rhacm2/multicluster-operators-subscription-rhel9:v2.10

      重要

      multicluster-operators-subscription 镜像的版本应与 RHACM 版本匹配。从 MCE 2.10 发行版本开始,RHEL 9 是 multicluster-operators-subscription 镜像的基础镜像。

    2. out/argocd/deployment/argocd-openshift-gitops-patch.json 文件中添加以下配置:

      {
        "args": [
          "-c",
          "mkdir -p /.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator && cp /policy-generator/PolicyGenerator-not-fips-compliant /.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator" 1
        ],
        "command": [
          "/bin/bash"
        ],
        "image": "registry.redhat.io/rhacm2/multicluster-operators-subscription-rhel9:v2.10", 2 3
        "name": "policy-generator-install",
        "imagePullPolicy": "Always",
        "volumeMounts": [
          {
            "mountPath": "/.config",
            "name": "kustomize"
          }
        ]
      }
      1
      可选: 对于 RHEL 9 镜像,在 ArgoCD 版本的 /policy-generator/PolicyGenerator-not-fips-compliant 文件夹中复制所需的通用可执行文件。
      2
      multicluster-operators-subscription 镜像与 RHACM 版本匹配。
      3
      在断开连接的环境中,将 multicluster-operators-subscription 镜像的 URL 替换为与您的环境中使用的断开连接的 registry。
    3. 对 ArgoCD 实例进行补丁。运行以下命令:

      $ oc patch argocd openshift-gitops \
      -n openshift-gitops --type=merge \
      --patch-file out/argocd/deployment/argocd-openshift-gitops-patch.json
  2. 在 RHACM 2.7 及更高版本中,多集群引擎默认启用 cluster-proxy-addon 功能。应用以下补丁来禁用 cluster-proxy-addon 功能,并删除负责此附加组件的相关 hub 集群和受管 pod。运行以下命令:

    $ oc patch multiclusterengines.multicluster.openshift.io multiclusterengine --type=merge --patch-file out/argocd/deployment/disable-cluster-proxy-addon.json
  3. 运行以下命令,将管道配置应用到 hub 集群:

    $ oc apply -k out/argocd/deployment
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.