This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.9.2.2. 阻塞特定的 registry
您可以通过编辑 image.config.openshift.io/cluster 自定义资源(CR)来阻塞 registry。OpenShift Container Platform 会将对此 CR 的更改应用到集群中的所有节点。
在拉取或推送镜像时,容器运行时会搜索 image.config.openshift.io/cluster CR 的 registrySources 参数中列出的 registry。如果您在 blockedRegistries 参数下创建了 registry 列表,则容器运行时不会搜索这些 registry。允许所有其他 registry。
为防止 pod 失败,请不要将 registry.redhat.io 和 quay.io registry 添加到 blockedRegistries 列表中,因为环境中有效负载镜像需要它们。
流程
编辑
image.config.openshift.io/clusterCR:oc edit image.config.openshift.io/cluster
$ oc edit image.config.openshift.io/clusterCopy to Clipboard Copied! Toggle word wrap Toggle overflow 以下是一个带有块列表的
image.config.openshift.io/clusterCR 示例:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 注意可以设置
blockedRegistriesregistry 或allowedRegistriesregistry,但不能同时设置这两个 registry。Machine Config Operator (MCO) 会监控
image.config.openshift.io/clusterCR 以了解对 registry 的任何更改,并在检测到更改时重启节点。对受阻 registry 的更改会出现在每个节点上的/etc/containers/registries.conf文件中。要检查 registry 是否已添加到策略文件中,请在节点上使用以下命令:
cat /host/etc/containers/registries.conf
$ cat /host/etc/containers/registries.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow 以下示例显示,在进行镜像拉取和推送时,不使用
untrusted.com:输出示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow