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.3. 允许不安全的 registry
您可以通过编辑 image.config.openshift.io/cluster
自定义资源(CR)来添加不安全的 registry。OpenShift Container Platform 会将对此 CR 的更改应用到集群中的所有节点。
没有使用有效 SSL 证书或不需要 HTTPS 连接的 registry 被视为是不安全的 registry。
应避免使用不安全的外部 registry,以减少可能的安全性风险。
流程
编辑
image.config.openshift.io/cluster
CR:oc edit image.config.openshift.io/cluster
$ oc edit image.config.openshift.io/cluster
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 以下是一个带有不安全 registry 列表的
image.config.openshift.io/cluster
CR 示例:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 注意当定义
allowedRegistries
参数时,除非明确列出,否则所有 registry(包括 registry.redhat.io 和 quay.io registry 和默认的内部镜像 registry)都会被阻断。如果使用参数,为了避免 pod 失败,将所有 registry(包括registry.redhat.io
和quay.io
registry)和internalRegistryHostname
添加到allowedRegistries
列表中,因为环境中有效负载镜像需要它们。对于断开连接的集群,还应添加镜像的 registry。Machine Config Operator(MCO)会监控
image.config.openshift.io/cluster
CR 是否有对 registry 的更改,然后在检测到更改时排空并取消记录节点。节点返回Ready
状态后,改为在每个节点的/etc/containers/registries.conf
文件中列出的不安全和受阻 registry。要检查 registry 是否已添加到策略文件中,请在节点上使用以下命令:
cat /host/etc/containers/registries.conf
$ cat /host/etc/containers/registries.conf
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 以下示例表示来自
insecure.com
registry 的镜像是不安全的,并允许进行镜像拉取和推送。输出示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow