17.2. 为 ZTP 准备 hub 集群
要在断开连接的环境中使用 RHACM,请创建一个镜像 registry,镜像 OpenShift Container Platform 发行镜像和包含所需 Operator 镜像的 Operator Lifecycle Manager (OLM) 目录。OLM 在集群中管理、安装和升级 Operator 及其依赖项。您还可以使用断开连接的镜像主机来提供用于置备裸机主机的 RHCOS ISO 和 RootFS 磁盘镜像。
17.2.1. 满足 Telco RAN 4.13 的解决方案软件版本
Red Hat Telco Radio Access Network (RAN) 版本 4.13 解决方案已使用以下红帽软件产品进行验证。
表 17.2. Telco RAN 4.13 验证的解决方案软件
| 产品 | 软件版本 |
|---|---|
| hub 集群 OpenShift Container Platform 版本 | 4.13 |
| GitOps ZTP 插件 | 4.11、4.12 或 4.13 |
| Red Hat Advanced Cluster Management (RHACM) | 2.7 |
| Red Hat OpenShift GitOps | 1.6 |
| Topology Aware Lifecycle Manager (TALM) | 4.11、4.12 或 4.13 |
17.2.2. 在断开连接的环境中安装 GitOps ZTP
在断开连接的环境中,使用 Red Hat Advanced Cluster Management (RHACM)、Red Hat OpenShift GitOps 和 Topology Aware Lifecycle Manager (TALM) 来管理多个受管集群的部署。
先决条件
-
已安装 OpenShift Container Platform CLI (
oc)。 -
您已以具有
cluster-admin权限的用户身份登录。 您已配置了断开连接的镜像 registry 以在集群中使用。
注意您创建的断开连接的镜像 registry 必须包含 TALM backup 和 pre-cache 镜像的版本,该镜像与 hub 集群中运行的 TALM 版本匹配。spoke 集群必须能够在断开连接的镜像 registry 中解析这些镜像。
流程
- 在 hub 集群上安装 RHACM。请参阅在断开连接的环境中安装 RHACM。
- 在 hub 集群中安装 GitOps 和 TALM。
17.2.3. 在断开连接的镜像主机中添加 RHCOS ISO 和 RootFS 镜像
在使用 Red Hat Advanced Cluster Management (RHACM) 在断开连接的环境中安装集群前,您必须首先托管 Red Hat Enterprise Linux CoreOS (RHCOS) 镜像供其使用。使用断开连接的镜像来托管 RHCOS 镜像。
先决条件
- 部署和配置 HTTP 服务器以托管网络上的 RHCOS 镜像资源。您必须能够从计算机以及您创建的机器访问 HTTP 服务器。
RHCOS 镜像可能不会随着 OpenShift Container Platform 的每个发行版本而改变。您必须下载最高版本的镜像,其版本号应小于或等于您安装的版本。如果可用,请使用与 OpenShift Container Platform 版本匹配的镜像版本。您需要 ISO 和 RootFS 镜像在主机上安装 RHCOS。此安装类型不支持 RHCOS QCOW2 镜像。
流程
- 登录到镜像主机。
从 mirror.openshift.com 获取 RHCOS ISO 和 RootFS 镜像,例如:
将所需的镜像名称和 OpenShift Container Platform 版本导出为环境变量:
$ export ISO_IMAGE_NAME=<iso_image_name> 1$ export ROOTFS_IMAGE_NAME=<rootfs_image_name> 1$ export OCP_VERSION=<ocp_version> 1下载所需的镜像:
$ sudo wget https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.13/${OCP_VERSION}/${ISO_IMAGE_NAME} -O /var/www/html/${ISO_IMAGE_NAME}$ sudo wget https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.13/${OCP_VERSION}/${ROOTFS_IMAGE_NAME} -O /var/www/html/${ROOTFS_IMAGE_NAME}
验证步骤
验证下载的镜像是否成功,并在断开连接的镜像主机上提供,例如:
$ wget http://$(hostname)/${ISO_IMAGE_NAME}输出示例
Saving to: rhcos-4.13.1-x86_64-live.x86_64.iso rhcos-4.13.1-x86_64-live.x86_64.iso- 11%[====> ] 10.01M 4.71MB/s
17.2.4. 在 hub 集群上启用驱动程序更新服务并更新 AgentServiceConfig
Red Hat Advanced Cluster Management (RHACM)使用辅助服务来部署 OpenShift Container Platform 集群。当使用中央基础架构管理 (CIM) 启用 MultiClusterHub Operator 时,辅助服务会自动部署。当您在 hub 集群上启用了 CIM 时,您需要更新 AgentServiceConfig 自定义资源 (CR),其引用托管在镜像 registry HTTP 服务器上的 ISO 和 RootFS 镜像。
先决条件
-
已安装 OpenShift CLI(
oc)。 -
已以具有
cluster-admin权限的用户身份登录到 hub 集群。 - 您已在 hub 集群中启用了辅助服务。如需更多信息,请参阅启用中央基础架构管理服务。
流程
运行以下命令来更新
AgentServiceConfigCR:$ oc edit AgentServiceConfig
在 CR 的
items.spec.osImages字段中添加以下条目:- cpuArchitecture: x86_64 openshiftVersion: "4.13" rootFSUrl: https://<host>/<path>/rhcos-live-rootfs.x86_64.img url: https://<mirror-registry>/<path>/rhcos-live.x86_64.iso其中:
- <host>
- 是目标镜像 registry HTTP 服务器的完全限定域名 (FQDN)。
- <path>
- 是目标镜像 registry 上镜像的路径。
保存并退出编辑器以应用更改。
17.2.5. 将 hub 集群配置为使用断开连接的镜像 registry
您可以将 hub 集群配置为使用断开连接的镜像 registry 作为断开连接的环境。
先决条件
- 已安装 Red Hat Advanced Cluster Management (RHACM) 2.8 的断开连接的 hub 集群安装。
-
您已在 HTTP 服务器中托管
rootfs和iso镜像。
如果为 HTTP 服务器启用 TLS,您必须确认 root 证书由客户端信任的颁发机构签名,并验证 OpenShift Container Platform hub 和受管集群和 HTTP 服务器之间的可信证书链。使用配置了不受信任的证书的服务器可防止将镜像下载到创建镜像中。不支持使用不受信任的 HTTPS 服务器。
流程
创建包含镜像 registry 配置的
ConfigMap:apiVersion: v1 kind: ConfigMap metadata: name: assisted-installer-config-map namespace: "<infrastructure_operator_namespace>" 1 labels: app: assisted-service data: ca-bundle.crt: | 2 -----BEGIN CERTIFICATE----- <certificate_contents> -----END CERTIFICATE----- registries.conf: | 3 unqualified-search-registries = ["registry.access.redhat.com", "docker.io"] [[registry]] prefix = "" location = "quay.io/example-repository" 4 mirror-by-digest-only = true [[registry.mirror]] location = "mirror1.registry.corp.com:5000/example-repository" 5
- 1
ConfigMap命名空间必须与 Infrastructure Operator 的命名空间相同。- 2
- 创建镜像 registry 时使用的镜像 registry 证书。
- 3
- 镜像 registry 的配置文件。镜像 registry 配置将镜像信息添加到发现镜像的
/etc/containers/registries.conf文件中。当信息传递给安装程序时,镜像信息会存储在install-config.yaml文件的imageContentSources部分中。在 hub 集群上运行的 Assisted Service pod 从配置的镜像 registry 获取容器镜像。 - 4
- 镜像 registry 的 URL。在配置镜像 registry 时,您必须运行
oc adm release mirror命令使用imageContentSources部分中的 URL。如需更多信息,请参阅 Mirroring the OpenShift Container Platform image repository 部分。 - 5
registries.conf文件中定义的 registry 必须由存储库范围,而不是由 registry 范围。在本例中,quay.io/example-repository和mirror1.registry.corp.com:5000/example-repository存储库都限定了example-repository存储库。
这会更新
AgentServiceConfig自定义资源中的mirrorRegistryRef,如下所示:输出示例
apiVersion: agent-install.openshift.io/v1beta1 kind: AgentServiceConfig metadata: name: agent spec: databaseStorage: volumeName: <db_pv_name> accessModes: - ReadWriteOnce resources: requests: storage: <db_storage_size> filesystemStorage: volumeName: <fs_pv_name> accessModes: - ReadWriteOnce resources: requests: storage: <fs_storage_size> mirrorRegistryRef: name: 'assisted-installer-mirror-config' osImages: - openshiftVersion: <ocp_version> url: <iso_url> 1- 1
- 必须与 HTTPD 服务器的 URL 匹配。
集群安装过程中需要一个有效的 NTP 服务器。确保有合适的 NTP 服务器可用,并可通过断开连接的网络从安装的系统访问。
17.2.6. 将 hub 集群配置为使用未经身份验证的 registry
您可以将 hub 集群配置为使用未经身份验证的 registry。未经身份验证的 registry 不需要进行身份验证才能访问和下载镜像。
先决条件
- 您已在 hub 集群上安装并配置了 hub 集群,并安装了 Red Hat Advanced Cluster Management (RHACM)。
- 已安装 OpenShift Container Platform CLI (oc)。
-
您已以具有
cluster-admin权限的用户身份登录。 - 已配置了一个未经身份验证的 registry 以用于 hub 集群。
流程
运行以下命令来更新
AgentServiceConfig自定义资源 (CR):$ oc edit AgentServiceConfig agent
在 CR 中添加
unauthenticatedRegistries字段:apiVersion: agent-install.openshift.io/v1beta1 kind: AgentServiceConfig metadata: name: agent spec: unauthenticatedRegistries: - example.registry.com - example.registry2.com ...
未经身份验证的 registry 在
AgentServiceConfig资源的spec.unauthenticatedRegistries下列出。任何此列表中的 registry 都不需要在用于 spoke 集群安装的 pull secret 中有一个条目。assisted-service通过确保包含用于安装的每个镜像 registry 的身份验证信息来验证 pull secret。
镜像 registry 会自动添加到 ignore 列表中,不需要在 spec.unauthenticatedRegistries 下添加。在 ConfigMap 中指定 PUBLIC_CONTAINER_REGISTRIES 环境变量会用指定的值覆盖默认值。PUBLIC_CONTAINER_REGISTRIES 默认值是 quay.io 和 registry.svc.ci.openshift.org。
验证
运行以下命令,验证您可以从 hub 集群访问新添加的 registry:
在 hub 集群中打开一个 debug shell 提示符:
$ oc debug node/<node_name>
运行以下命令测试对未经身份验证的 registry 的访问:
sh-4.4# podman login -u kubeadmin -p $(oc whoami -t) <unauthenticated_registry>
其中:
- <unauthenticated_registry>
-
新的 registry,如
unauthenticated-image-registry.openshift-image-registry.svc:5000。
输出示例
Login Succeeded!
17.2.7. 使用 ArgoCD 配置 hub 集群
您可以使用一组 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目录。
流程
准备 ArgoCD 管道配置:
- 创建 Git 存储库,其目录结构类似于 example 目录。如需更多信息,请参阅"准备 GitOps ZTP 站点配置存储库"。
使用 ArgoCD UI 配置对存储库的访问。在 Settings 下配置以下内容:
-
Repositories - 添加连接信息。URL 必须以
.git结尾,例如https://repo.example.com/repo.git和凭证。 - 证书 - 如果需要,为存储库添加公共证书。
-
Repositories - 添加连接信息。URL 必须以
根据您的 Git 仓库修改两个 ArgoCD 应用程序,
out/argocd/deployment/clusters-app.yaml和out/argocd/deployment/policies-app.yaml:-
更新 URL 以指向 Git 存储库。URL 以
.git结尾,例如https://repo.example.com/repo.git。 -
targetRevision表示要监控的 Git 存储库分支。 -
path指定到SiteConfig和PolicyGenTemplateCR 的路径。
-
更新 URL 以指向 Git 存储库。URL 以
要安装 GitOps ZTP 插件,您必须使用之前提取到
out/argocd/deployment/目录中的补丁文件来修补 hub 集群中的 ArgoCD 实例。运行以下命令:$ oc patch argocd openshift-gitops \ -n openshift-gitops --type=merge \ --patch-file out/argocd/deployment/argocd-openshift-gitops-patch.json
使用以下命令将管道配置应用到 hub 集群:
$ oc apply -k out/argocd/deployment
17.2.8. 准备 GitOps ZTP 站点配置存储库
在使用 GitOps Zero Touch Provisioning (ZTP) 管道前,您需要准备 Git 存储库来托管站点配置数据。
先决条件
- 已配置了 hub 集群 GitOps 应用程序来生成所需的安装和策略自定义资源 (CR)。
- 已使用 GitOps ZTP 部署受管集群。
流程
-
使用
SiteConfig和PolicyGenTemplateCR 的单独路径创建一个目录结构。 使用以下命令,从
ztp-site-generate容器镜像导出argocd目录:$ podman pull registry.redhat.io/openshift4/ztp-site-generate-rhel8:v4.13
$ mkdir -p ./out
$ podman run --log-driver=none --rm registry.redhat.io/openshift4/ztp-site-generate-rhel8:v4.13 extract /home/ztp --tar | tar x -C ./out
检查
out目录是否包含以下子目录:-
out/extra-manifest包含SiteConfig用来生成额外清单configMap的源 CR 文件。 -
out/source-crs包含PolicyGenTemplate用来生成 Red Hat Advanced Cluster Management(RHACM)策略的源 CR 文件。 -
out/argocd/deployment包含补丁和 YAML 文件,可在 hub 集群中应用,以便在此过程的下一步中使用。 -
out/argocd/example包含代表推荐的配置的siteConfig和PolicyGenTemplate文件的示例。
-
out/argocd/example 下的目录结构充当 Git 存储库结构和内容的参考。示例包括用于单节点、三节点和标准集群的 SiteConfig 和 PolicyGenTemplate 引用 CR。删除您对未使用集群类型的引用。以下示例描述了单节点集群网络的一组 CR:
example
├── policygentemplates
│ ├── common-ranGen.yaml
│ ├── example-sno-site.yaml
│ ├── group-du-sno-ranGen.yaml
│ ├── group-du-sno-validator-ranGen.yaml
│ ├── kustomization.yaml
│ └── ns.yaml
└── siteconfig
├── example-sno.yaml
├── KlusterletAddonConfigOverride.yaml
└── kustomization.yaml
在单独的目录中,保持 SiteConfig 和 PolicyGenTemplate CR。SiteConfig 和 PolicyGenTemplate 目录必须包含一个 kustomization.yaml 文件,该文件明确包含该目录中的文件。
此目录结构以及 kustomization.yaml 文件必须提交并推送到 Git 存储库。初始推送到 Git 的推送应包含 kustomization.yaml 文件。在部署站点时,可以忽略 SiteConfig (example-sno.yaml) 和 PolicyGenTemplate (common-ranGen.yaml, group-du-sno*.yaml, and example-sno-site.yaml) 文件,并在以后需要时在推送它们。
只有在提交并推送到 Git 的一个或多个 SiteConfig CR 时,才需要 KlusterletAddonConfigOverride.yaml 文件。如需有关如何使用的示例,请参阅 example-sno.yaml。