7.17. 为断开连接的集群配置镜像流
在断开连接的环境中安装 OpenShift Container Platform 后,为 Cluster Samples Operator 和 must-gather 镜像流配置镜像流。
7.17.1. 协助镜像的 Cluster Samples Operator
在安装过程中,OpenShift Container Platform 在 openshift-cluster-samples-operator 命名空间中创建一个名为 imagestreamtag-to-image 的配置映射。imagestreamtag-to-image 配置映射包含每个镜像流标签的条目(填充镜像)。
配置映射中 data 字段中每个条目的键格式为 <image_stream_name>_<image_stream_tag_name>。
在断开连接的 OpenShift Container Platform 安装过程中,Cluster Samples Operator 的状态被设置为 Removed。如果您将其改为 Managed,它会安装示例。
在网络限制或断开连接的环境中使用示例可能需要通过网络访问服务。某些示例服务包括:Github、Maven Central、npm、RubyGems、PyPi 等。这可能需要执行额外的步骤,让集群 samples operator 对象能够访问它们所需的服务。
您可以使用此配置映射作为导入镜像流所需的镜像的引用。
-
在 Cluster Samples Operator 被设置为
Removed时,您可以创建镜像的 registry,或决定您要使用哪些现有镜像 registry。 - 使用新的配置映射作为指南来镜像您要镜像的 registry 的示例。
-
将没有镜像的任何镜像流添加到 Cluster Samples Operator 配置对象的
skippedImagestreams列表中。 -
将 Cluster Samples Operator 配置对象的
samplesRegistry设置为已镜像的 registry。 -
然后,将 Cluster Samples Operator 设置为
Managed来安装您已镜像的镜像流。
7.17.2. 使用带有备用或镜像 registry 的 Cluster Samples Operator 镜像流
openshift 命名空间中大多数由 Cluster Samples Operator 管理的镜像流指向位于 registry.redhat.io 上红帽容器镜像仓库中的镜像。镜像功能不适用于这些镜像流。
cli、installer、must-gather 和 test 镜像流虽然属于安装有效负载的一部分,但不由 Cluster Samples Operator 管理。此流程中不涉及这些镜像流。
Cluster Samples Operator 必须在断开连接的环境中设置为 Managed。要安装镜像流,您需要有一个镜像的 registry。
先决条件
-
使用具有
cluster-admin角色的用户访问集群。 - 为您的镜像 registry 创建 pull secret。
流程
访问被镜像(mirror)的特定镜像流的镜像,例如:
$ oc get is <imagestream> -n openshift -o json | jq .spec.tags[].from.name | grep registry.redhat.io
将 registry.redhat.io 中与您在受限网络环境中需要的任何镜像流关联的镜像,镜像 (mirror) 成一个定义的镜像 (mirror):
$ oc image mirror registry.redhat.io/rhscl/ruby-25-rhel7:latest ${MIRROR_ADDR}/rhscl/ruby-25-rhel7:latest创建集群的镜像配置对象:
$ oc create configmap registry-config --from-file=${MIRROR_ADDR_HOSTNAME}..5000=$path/ca.crt -n openshift-config在集群的镜像配置对象中,为镜像添加所需的可信 CA:
$ oc patch image.config.openshift.io/cluster --patch '{"spec":{"additionalTrustedCA":{"name":"registry-config"}}}' --type=merge更新 Cluster Samples Operator 配置对象中的
samplesRegistry字段,使其包含镜像配置中定义的镜像位置的hostname部分:$ oc edit configs.samples.operator.openshift.io -n openshift-cluster-samples-operator
注意这是必要的,因为镜像流导入过程在此刻不使用镜像(mirro)或搜索机制。
将所有未镜像的镜像流添加到 Cluster Samples Operator 配置对象的
skippedImagestreams字段。或者,如果您不想支持任何示例镜像流,在 Cluster Samples Operator 配置对象中将 Cluster Samples Operator 设置为Removed。注意如果镜像流导入失败,Cluster Samples Operator 会发出警告,但 Cluster Samples Operator 会定期重试,或看起来并没有重试它们。
openshift命名空间中的许多模板都引用镜像流。因此,使用Removed清除镜像流和模板,将避免在因为缺少镜像流而导致镜像流和模板无法正常工作时使用它们。
7.17.3. 准备集群以收集支持数据
使用受限网络的集群必须导入默认的 must-gather 镜像,以便为红帽支持收集调试数据。在默认情况下,must-gather 镜像不会被导入,受限网络中的集群无法访问互联网来从远程存储库拉取最新的镜像。
流程
如果您还没有将镜像 registry 的可信 CA 添加到集群的镜像配置对象中,作为 Cluster Samples Operator 配置的一部分,请执行以下步骤:
创建集群的镜像配置对象:
$ oc create configmap registry-config --from-file=${MIRROR_ADDR_HOSTNAME}..5000=$path/ca.crt -n openshift-config在集群的镜像配置对象中,为镜像添加所需的可信 CA:
$ oc patch image.config.openshift.io/cluster --patch '{"spec":{"additionalTrustedCA":{"name":"registry-config"}}}' --type=merge
从您的安装有效负载中导入默认 must-gather 镜像:
$ oc import-image is/must-gather -n openshift
在运行 oc adm must-gather 命令时,请使用 --image 标志并指向有效负载镜像,如下例所示:
$ oc adm must-gather --image=$(oc adm release info --image-for must-gather)