4.11. 包括本地 OCI Operator 目录
虽然将 OpenShift Container Platform 发行版本、Operator 目录和其他额外的镜像从 registry mirror 到一个部分断开连接的集群中,但您还可以在一个本地磁盘中的基于文件的目录中包含 Operator 目录镜像。本地目录必须采用开放容器项目 (OCI) 格式。
本地目录及其内容会根据镜像设置配置文件中的过滤信息,mirror 到您的目标 mirror registry。
在镜像本地 OCI 目录时,所有您要 mirror 的 OpenShift Container Platform 发行版本或其他需要和本地 OCI 格式目录一起 mirror 的镜像都必须从 registry 中拉取。
您无法在磁盘中一起 mirror OCI 目录和一个 oc-mirror 镜像集文件镜像。
使用 OCI 功能的一个用例是,您有一个 CI/CD 系统将 OCI 目录构建到磁盘上的位置,并需要将 OCI 目录以及 OpenShift Container Platform 发行版本一起 mirror 到您的 mirror 镜像 registry。
如果您为 OpenShift Container Platform 4.12 的 oc-mirror 插件使用了预览预览的 OCI 本地目录功能,则无法再使用 oc-mirror 插件的 OCI 本地目录功能在本地复制目录,并将其转换为 OCI 格式作为 mirror 到一个完全断开连接的集群中的第一步。
先决条件
- 您可以访问互联网来获取所需的容器镜像。
-
已安装 OpenShift CLI(
oc
)。 -
已安装
oc-mirror
CLI 插件。
流程
创建镜像设置配置文件,并根据需要调整设置。
以下示例镜像设置配置在磁盘上 mirror 一个 OCI 目录,以及来自
registry.redhat.io
的 OpenShift Container Platform 发行版本和 UBI 镜像。kind: ImageSetConfiguration apiVersion: mirror.openshift.io/v1alpha2 storageConfig: local: path: /home/user/metadata 1 mirror: platform: channels: - name: stable-4.13 2 type: ocp graph: false operators: - catalog: oci:///home/user/oc-mirror/my-oci-catalog 3 targetCatalog: my-namespace/redhat-operator-index 4 packages: - name: aws-load-balancer-operator - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.13 5 packages: - name: rhacs-operator additionalImages: - name: registry.redhat.io/ubi9/ubi:latest 6
运行
oc mirror
命令将 OCI 目录 mirror 到目标 mirror registry:$ oc mirror --config=./imageset-config.yaml \ 1 --include-local-oci-catalogs 2 docker://registry.example:5000 3
另外,您可以指定其他标记来调整 OCI 功能的行为:
--oci-insecure-signature-policy
- 不要将签名推送到目标 mirror registry。
--oci-registries-config
指定 TOML 格式的
registry.conf
文件的路径。您可以使用它来从不同的 registry 中镜像,如用于测试的预生产位置,而无需更改镜像设置配置文件。这个标志只会影响本地 OCI 目录,而不会影响任何其他被镜像的内容。registry.conf 文件示例
[[registry]] location = "registry.redhat.io:5000" insecure = false blocked = false mirror-by-digest-only = true prefix = "" [[registry.mirror]] location = "preprod-registry.example.com" insecure = false
后续步骤
- 配置集群以使用 oc-mirror 生成的资源。