allowedRegistriesForImport
image.config.openshift.io/cluster
资源保存有关如何处理镜像的集群范围信息。规范且唯一有效的名称是 cluster
。它的 spec
提供以下配置参数。
诸如 |
参数 | 描述 |
---|---|
|
限制普通用户可以从中导入镜像的容器镜像仓库。将此列表设置为您信任的包含有效镜像且希望应用程序能够从中导入镜像的仓库。拥有从API创建镜像或 此列表的每个元素都包含由仓库域名指定的仓库位置。
|
|
对包含在 此配置映射的命名空间是 |
|
提供默认外部镜像仓库的主机名。只有当镜像仓库在外部公开时,才应设置外部主机名。第一个值用于镜像流中的 |
|
包含确定容器运行时在访问构建和pod的镜像时如何处理各个仓库的配置。例如,是否允许不安全访问。它不包含内部集群仓库的配置。
可以设置 |
当定义 |
image.config.openshift.io/cluster
资源的status
字段保存来自集群的观察值。
参数 | 描述 |
---|---|
|
由镜像仓库操作符设置,该操作符控制 |
|
由镜像仓库操作符设置,在镜像仓库在外部公开时提供镜像仓库的外部主机名。第一个值用于镜像流中的 |
您可以通过编辑image.config.openshift.io/cluster
自定义资源 (CR) 来配置镜像仓库设置。当对仓库的更改应用于image.config.openshift.io/cluster
CR 时,机器配置操作符 (MCO) 会执行以下顺序操作
隔离节点
通过重新启动CRI-O来应用更改
取消隔离节点
当MCO检测到更改时,它不会重新启动节点。 |
编辑image.config.openshift.io/cluster
自定义资源
$ oc edit image.config.openshift.io/cluster
以下是一个示例image.config.openshift.io/cluster
CR
apiVersion: config.openshift.io/v1
kind: Image (1)
metadata:
annotations:
release.openshift.io/create-only: "true"
creationTimestamp: "2019-05-17T13:44:26Z"
generation: 1
name: cluster
resourceVersion: "8302"
selfLink: /apis/config.openshift.io/v1/images/cluster
uid: e34555da-78a9-11e9-b92b-06d6c7da38dc
spec:
allowedRegistriesForImport: (2)
- domainName: quay.io
insecure: false
additionalTrustedCA: (3)
name: myconfigmap
registrySources: (4)
allowedRegistries:
- example.com
- quay.io
- registry.redhat.io
- image-registry.openshift-image-registry.svc:5000
- reg1.io/myrepo/myapp:latest
insecureRegistries:
- insecure.com
status:
internalRegistryHostname: image-registry.openshift-image-registry.svc:5000
1 | Image :保存有关如何处理镜像的集群范围信息。规范且唯一有效的名称是cluster 。 |
2 | allowedRegistriesForImport :限制普通用户可以从中导入容器镜像的镜像仓库。将此列表设置为您信任的包含有效镜像并希望应用程序能够从中导入镜像的仓库。拥有通过 API 创建镜像或ImageStreamMappings 权限的用户不受此策略的影响。通常只有集群管理员才有相应的权限。 |
3 | additionalTrustedCA :指向一个 ConfigMap 的引用,该 ConfigMap 包含在镜像流导入、Pod 镜像拉取、openshift-image-registry 透传和构建期间受信任的额外证书颁发机构 (CA)。此 ConfigMap 的命名空间为openshift-config 。ConfigMap 的格式是使用注册表主机名作为键,使用 PEM 证书作为值,用于每个需要信任的额外注册表 CA。 |
4 | registrySources :包含确定容器运行时在访问构建和 Pod 的镜像时允许或阻止各个注册表的配置。可以设置allowedRegistries 参数或blockedRegistries 参数,但不能同时设置两者。您还可以定义是否允许访问不安全的注册表或允许使用镜像短名称的注册表。此示例使用allowedRegistries 参数,该参数定义允许使用的注册表。不安全的注册表insecure.com 也被允许。registrySources 参数不包含内部集群注册表的配置。 |
定义 使用 应避免使用不安全的外部注册表,以降低可能的安全风险。 |
要检查更改是否已应用,请列出您的节点。
$ oc get nodes
NAME STATUS ROLES AGE VERSION
ip-10-0-137-182.us-east-2.compute.internal Ready,SchedulingDisabled worker 65m v1.30.3
ip-10-0-139-120.us-east-2.compute.internal Ready,SchedulingDisabled control-plane 74m v1.30.3
ip-10-0-176-102.us-east-2.compute.internal Ready control-plane 75m v1.30.3
ip-10-0-188-96.us-east-2.compute.internal Ready worker 65m v1.30.3
ip-10-0-200-59.us-east-2.compute.internal Ready worker 63m v1.30.3
ip-10-0-223-123.us-east-2.compute.internal Ready control-plane 73m v1.30.3
您可以添加允许进行镜像拉取和推送操作的注册表列表,以及可选的注册表中的单个仓库,方法是编辑image.config.openshift.io/cluster
自定义资源 (CR)。AWS 上的 Red Hat OpenShift Service 会将对该 CR 的更改应用于集群中的所有节点。
拉取或推送镜像时,容器运行时会在image.config.openshift.io/cluster
CR 中的registrySources
参数下列出的注册表中搜索。如果您在allowedRegistries
参数下创建了注册表列表,则容器运行时仅搜索这些注册表。列表中不存在的注册表将被阻止。
定义 |
编辑image.config.openshift.io/cluster
自定义资源
$ oc edit image.config.openshift.io/cluster
以下是包含允许列表的image.config.openshift.io/cluster
CR 示例
apiVersion: config.openshift.io/v1
kind: Image
metadata:
annotations:
release.openshift.io/create-only: "true"
creationTimestamp: "2019-05-17T13:44:26Z"
generation: 1
name: cluster
resourceVersion: "8302"
selfLink: /apis/config.openshift.io/v1/images/cluster
uid: e34555da-78a9-11e9-b92b-06d6c7da38dc
spec:
registrySources: (1)
allowedRegistries: (2)
- example.com
- quay.io
- registry.redhat.io
- reg1.io/myrepo/myapp:latest
- image-registry.openshift-image-registry.svc:5000
status:
internalRegistryHostname: image-registry.openshift-image-registry.svc:5000
1 | 包含确定容器运行时在访问构建和 Pod 的镜像时如何处理各个注册表的配置。它不包含内部集群注册表的配置。 |
2 | 指定注册表(以及可选的该注册表中的仓库),用于镜像拉取和推送操作。所有其他注册表都将被阻止。 |
可以设置 |
机器配置操作员 (MCO) 会监视image.config.openshift.io/cluster
资源中注册表的任何更改。当 MCO 检测到更改时,它会将节点 drain,应用更改,然后取消节点 cordon。节点返回到Ready
状态后,将使用允许的注册表列表更新每个节点上的/etc/containers/policy.json
文件中的镜像签名策略。
如果您的集群使用 例如
|
您可以阻止任何注册表,以及可选的注册表中的单个仓库,方法是编辑image.config.openshift.io/cluster
自定义资源 (CR)。AWS 上的 Red Hat OpenShift Service 会将对该 CR 的更改应用于集群中的所有节点。
拉取或推送镜像时,容器运行时会在image.config.openshift.io/cluster
CR 中的registrySources
参数下列出的注册表中搜索。如果您在blockedRegistries
参数下创建了注册表列表,则容器运行时不会搜索这些注册表。所有其他注册表都将被允许。
为了防止 Pod 失败,请不要将 |
编辑image.config.openshift.io/cluster
自定义资源
$ oc edit image.config.openshift.io/cluster
以下是包含阻止列表的image.config.openshift.io/cluster
CR 示例
apiVersion: config.openshift.io/v1
kind: Image
metadata:
annotations:
release.openshift.io/create-only: "true"
creationTimestamp: "2019-05-17T13:44:26Z"
generation: 1
name: cluster
resourceVersion: "8302"
selfLink: /apis/config.openshift.io/v1/images/cluster
uid: e34555da-78a9-11e9-b92b-06d6c7da38dc
spec:
registrySources: (1)
blockedRegistries: (2)
- untrusted.com
- reg1.io/myrepo/myapp:latest
status:
internalRegistryHostname: image-registry.openshift-image-registry.svc:5000
1 | 包含确定容器运行时在访问构建和 Pod 的镜像时如何处理各个注册表的配置。它不包含内部集群注册表的配置。 |
2 | 指定不应用于镜像拉取和推送操作的注册表(以及可选的该注册表中的仓库)。所有其他注册表都将被允许。 |
可以设置 |
机器配置操作员 (MCO) 会监视image.config.openshift.io/cluster
资源中注册表的任何更改。当 MCO 检测到更改时,它会将节点 drain,应用更改,然后取消节点 cordon。节点返回到Ready
状态后,对阻止注册表的更改将出现在每个节点上的/etc/containers/registries.conf
文件中。
您可以添加不安全的注册表,以及可选的注册表中的单个仓库,方法是编辑image.config.openshift.io/cluster
自定义资源 (CR)。AWS 上的 Red Hat OpenShift Service 会将对该 CR 的更改应用于集群中的所有节点。
不使用有效的 SSL 证书或不需要 HTTPS 连接的注册表被认为是不安全的。
应避免使用不安全的外部注册表,以降低可能的安全风险。 |
编辑image.config.openshift.io/cluster
自定义资源
$ oc edit image.config.openshift.io/cluster
以下是包含不安全注册表列表的image.config.openshift.io/cluster
CR 示例
apiVersion: config.openshift.io/v1
kind: Image
metadata:
annotations:
release.openshift.io/create-only: "true"
creationTimestamp: "2019-05-17T13:44:26Z"
generation: 1
name: cluster
resourceVersion: "8302"
selfLink: /apis/config.openshift.io/v1/images/cluster
uid: e34555da-78a9-11e9-b92b-06d6c7da38dc
spec:
registrySources: (1)
insecureRegistries: (2)
- insecure.com
- reg4.io/myrepo/myapp:latest
allowedRegistries:
- example.com
- quay.io
- registry.redhat.io
- insecure.com (3)
- reg4.io/myrepo/myapp:latest
- image-registry.openshift-image-registry.svc:5000
status:
internalRegistryHostname: image-registry.openshift-image-registry.svc:5000
1 | 包含确定容器运行时在访问构建和 Pod 的镜像时如何处理各个注册表的配置。它不包含内部集群注册表的配置。 |
2 | 指定不安全的注册表。您可以指定该注册表中的仓库。 |
3 | 确保允许列表中包含任何不安全的注册表。 |
如果定义了 |
机器配置操作符 (MCO) 监视image.config.openshift.io/cluster
CR 中注册表的任何更改,然后在检测到更改时会将节点 drain 并取消 cordon。节点恢复到Ready
状态后,不安全和被阻止的注册表更改将显示在每个节点上的/etc/containers/registries.conf
文件中。
您可以通过编辑image.config.openshift.io/cluster
自定义资源 (CR) 来添加用于搜索镜像简短名称的注册表。AWS 上的 Red Hat OpenShift Service 会将此 CR 的更改应用于集群中的所有节点。
镜像简短名称使您可以搜索镜像,而无需在拉取规范中包含完全限定的域名。例如,您可以使用rhel7/etcd
而不是registry.access.redhat.com/rhe7/etcd
。
在使用完整路径不切实际的情况下,您可能会使用简短名称。例如,如果您的集群引用多个内部注册表,并且其 DNS 频繁更改,则需要在每次更改时更新拉取规范中的完全限定域名。在这种情况下,使用镜像简短名称可能会有益。
拉取或推送镜像时,容器运行时会在image.config.openshift.io/cluster
CR 的registrySources
参数下列出的注册表中搜索。如果您在containerRuntimeSearchRegistries
参数下创建了一个注册表列表,则在使用简短名称拉取镜像时,容器运行时会在这些注册表中搜索。
强烈建议不要将镜像简短名称与公共注册表一起使用,因为如果公共注册表需要身份验证,则镜像可能无法部署。请对公共注册表使用完全限定的镜像名称。 Red Hat 内部或私有注册表通常支持使用镜像简短名称。 如果您在 如果每个公共注册表都需要不同的凭据,并且集群未在全局拉取密钥中列出公共注册表,则您不能在 对于需要身份验证的公共注册表,只有在注册表的凭据存储在全局拉取密钥中时,才能使用镜像简短名称。 |
机器配置操作符 (MCO) 监视image.config.openshift.io/cluster
资源中注册表的任何更改。当 MCO 检测到更改时,它会将节点 drain,应用更改,然后取消 cordon 节点。节点恢复到Ready
状态后,如果添加了containerRuntimeSearchRegistries
参数,则 MCO 会在每个节点上的/etc/containers/registries.conf.d
目录中创建一个包含列出注册表的文件。该文件将覆盖/etc/containers/registries.conf
文件中未限定搜索注册表的默认列表。无法回退到未限定搜索注册表的默认列表。
containerRuntimeSearchRegistries
参数仅适用于 Podman 和 CRI-O 容器引擎。列表中的注册表只能在 Pod 规范中使用,不能在构建和镜像流中使用。
编辑image.config.openshift.io/cluster
自定义资源
$ oc edit image.config.openshift.io/cluster
以下是一个示例image.config.openshift.io/cluster
CR
apiVersion: config.openshift.io/v1
kind: Image
metadata:
annotations:
release.openshift.io/create-only: "true"
creationTimestamp: "2019-05-17T13:44:26Z"
generation: 1
name: cluster
resourceVersion: "8302"
selfLink: /apis/config.openshift.io/v1/images/cluster
uid: e34555da-78a9-11e9-b92b-06d6c7da38dc
spec:
allowedRegistriesForImport:
- domainName: quay.io
insecure: false
additionalTrustedCA:
name: myconfigmap
registrySources:
containerRuntimeSearchRegistries: (1)
- reg1.io
- reg2.io
- reg3.io
allowedRegistries: (2)
- example.com
- quay.io
- registry.redhat.io
- reg1.io
- reg2.io
- reg3.io
- image-registry.openshift-image-registry.svc:5000
...
status:
internalRegistryHostname: image-registry.openshift-image-registry.svc:5000
1 | 指定要与镜像简短名称一起使用的注册表。您应该只对内部或私有注册表使用镜像简短名称,以降低可能的安全风险。 |
2 | 确保containerRuntimeSearchRegistries 下列出的任何注册表都包含在allowedRegistries 列表中。 |
如果定义了 |
image.config.openshift.io/cluster
自定义资源可以包含对包含其他证书颁发机构的配置映射的引用,这些证书颁发机构在镜像注册表访问期间应受信任。
证书颁发机构 (CA) 必须是 PEM 编码的。
您可以在openshift-config
命名空间中创建配置映射,并在image.config.openshift.io
自定义资源中的AdditionalTrustedCA
中使用其名称来提供联系外部注册表时应受信任的其他 CA。
配置映射键是具有端口的注册表的 hostname,为此 CA 应受信任,并且 PEM 证书内容是每个其他注册表 CA 的值。
apiVersion: v1
kind: ConfigMap
metadata:
name: my-registry-ca
data:
registry.example.com: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
registry-with-port.example.com..5000: | (1)
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
1 | 如果注册表具有端口,例如registry-with-port.example.com:5000 ,则应将: 替换为.. 。 |
您可以按照以下步骤配置其他 CA。
配置其他 CA
$ oc create configmap registry-config --from-file=<external_registry_address>=ca.crt -n openshift-config
$ oc edit image.config.openshift.io cluster
spec:
additionalTrustedCA:
name: registry-config
设置容器注册表仓库镜像使您可以执行以下任务
配置您的 AWS 上的 Red Hat OpenShift Service 集群,以重定向请求以从源镜像注册表上的仓库拉取镜像,并使其由镜像镜像注册表上的仓库解析。
为每个目标仓库标识多个镜像仓库,以确保如果一个镜像不可用,则可以使用另一个镜像。
AWS 上的 Red Hat OpenShift Service 中的仓库镜像包括以下属性
镜像拉取能够应对注册表宕机。
断开连接的环境中的集群可以从关键位置(例如 quay.io)拉取镜像,并且公司防火墙后面的注册表可以提供请求的镜像。
发出镜像拉取请求时,会尝试特定顺序的注册表,永久注册表通常是最后尝试的一个。
您输入的镜像信息将添加到 AWS 上的 Red Hat OpenShift Service 集群中每个节点上的/etc/containers/registries.conf
文件中。
当节点向源仓库请求镜像时,它会依次尝试每个镜像仓库,直到找到请求的内容。如果所有镜像都失败,集群会尝试源仓库。如果成功,则将镜像拉取到节点。
设置仓库镜像可以通过以下方式完成
在 AWS 上的 Red Hat OpenShift Service 安装期间
通过拉取 AWS 上的 Red Hat OpenShift Service 所需的容器镜像,然后将这些镜像置于公司防火墙之后,您可以将 AWS 上的 Red Hat OpenShift Service 安装到断开连接的环境中的数据中心。
在 AWS 上的 Red Hat OpenShift Service 安装之后
如果您在 AWS 上的 Red Hat OpenShift Service 安装期间未配置镜像,则可以在安装后使用以下任何自定义资源 (CR) 对象来进行配置
ImageDigestMirrorSet
(IDMS)。此对象允许您通过使用摘要规范从镜像注册表拉取镜像。IDMS CR 使您可以设置回退策略,如果镜像拉取失败,则允许或停止继续尝试从源注册表拉取。
ImageTagMirrorSet
(ITMS):此对象允许您使用镜像标签从镜像注册表拉取镜像。ITMS CR 使您可以设置回退策略,如果镜像拉取失败,则允许或停止继续尝试从源注册表拉取。
ImageContentSourcePolicy
(ICSP):此对象允许您使用摘要规范从镜像注册表拉取镜像。如果镜像不起作用,ICSP CR 将始终回退到源注册表。
使用 |
每个自定义资源对象都标识以下信息:
您要镜像的容器镜像存储库的源。
您要为从源存储库请求的内容提供的每个镜像存储库的单独条目。
对于新的集群,您可以根据需要使用 IDMS、ITMS 和 ICSP CR 对象。但是,建议使用 IDMS 和 ITMS。
如果您升级了集群,任何现有的 ICSP 对象都保持稳定,并且支持 IDMS 和 ICSP 对象。使用 ICSP 对象的工作负载将继续按预期运行。但是,如果您想利用 IDMS CR 中引入的回退策略,您可以使用oc adm migrate icsp
命令将当前工作负载迁移到 IDMS 对象,如后面的转换用于镜像注册表存储库镜像的 ImageContentSourcePolicy (ICSP) 文件部分所示。迁移到 IDMS 对象不需要重新启动集群。
如果您的集群使用 |
您可以创建安装后镜像配置自定义资源 (CR) 以将镜像拉取请求从源镜像注册表重定向到镜像镜像注册表。
作为具有dedicated-admin
角色的用户访问集群。
配置镜像存储库,方法如下:
使用 Red Hat Quay 设置镜像存储库,如Red Hat Quay 存储库镜像中所述。使用 Red Hat Quay 允许您将镜像从一个存储库复制到另一个存储库,并随着时间的推移自动重复同步这些存储库。
使用skopeo
等工具手动将镜像从源存储库复制到镜像存储库。
例如,在 Red Hat Enterprise Linux (RHEL) 7 或 RHEL 8 系统上安装 skopeo RPM 软件包后,请使用以下示例中所示的skopeo
命令:
$ skopeo copy --all \
docker://registry.access.redhat.com/ubi9/ubi-minimal:latest@sha256:5cf... \
docker://example.io/example/ubi-minimal
在此示例中,您有一个名为example.io
的容器镜像注册表,其中有一个名为example
的镜像存储库,您要将ubi9/ubi-minimal
镜像从registry.access.redhat.com
复制到该存储库。创建镜像注册表后,您可以配置您的 Red Hat OpenShift Service on AWS 集群以将对源存储库的请求重定向到镜像存储库。
使用以下示例之一创建安装后镜像配置 CR:
根据需要创建ImageDigestMirrorSet
或ImageTagMirrorSet
CR,将源和镜像替换为您自己的注册表和存储库对以及镜像。
apiVersion: config.openshift.io/v1 (1)
kind: ImageDigestMirrorSet (2)
metadata:
name: ubi9repo
spec:
imageDigestMirrors: (3)
- mirrors:
- example.io/example/ubi-minimal (4)
- example.com/example/ubi-minimal (5)
source: registry.access.redhat.com/ubi9/ubi-minimal (6)
mirrorSourcePolicy: AllowContactingSource (7)
- mirrors:
- mirror.example.com/redhat
source: registry.example.com/redhat (8)
mirrorSourcePolicy: AllowContactingSource
- mirrors:
- mirror.example.com
source: registry.example.com (9)
mirrorSourcePolicy: AllowContactingSource
- mirrors:
- mirror.example.net/image
source: registry.example.com/example/myimage (10)
mirrorSourcePolicy: AllowContactingSource
- mirrors:
- mirror.example.net
source: registry.example.com/example (11)
mirrorSourcePolicy: AllowContactingSource
- mirrors:
- mirror.example.net/registry-example-com
source: registry.example.com (12)
mirrorSourcePolicy: AllowContactingSource
1 | 指示要与此 CR 一起使用的 API。这必须是config.openshift.io/v1 。 |
2 | 根据拉取类型指示对象的类型。
|
3 | 指示镜像拉取方法的类型:
|
4 | 指示镜像镜像注册表和存储库的名称。 |
5 | 可选:为每个目标存储库指示辅助镜像存储库。如果一个镜像关闭,目标存储库可以使用辅助镜像。 |
6 | 指示注册表和存储库源,即镜像拉取规范中引用的存储库。 |
7 | 可选:如果镜像拉取失败,则指示回退策略。
|
8 | 可选:指示注册表内的命名空间,允许您使用该命名空间中的任何镜像。如果您使用注册表域作为源,则该对象将应用于该注册表中的所有存储库。 |
9 | 可选:指示注册表,允许您使用该注册表中的任何镜像。如果您指定注册表名称,则该对象将应用于从源注册表到镜像注册表的所有存储库。 |
10 | 从镜像mirror.example.net/image@sha256:.. 拉取镜像registry.example.com/example/myimage@sha256:… 。 |
11 | 从镜像mirror.example.net/image@sha256:… 拉取源注册表命名空间中的镜像registry.example.com/example/image@sha256:… 。 |
12 | 从镜像注册表example.net/registry-example-com/myimage@sha256:… 拉取镜像registry.example.com/myimage@sha256 。 |
创建一个ImageContentSourcePolicy
自定义资源,将源和镜像替换为您自己的注册表和存储库对以及镜像。
apiVersion: operator.openshift.io/v1alpha1
kind: ImageContentSourcePolicy
metadata:
name: mirror-ocp
spec:
repositoryDigestMirrors:
- mirrors:
- mirror.registry.com:443/ocp/release (1)
source: quay.io/openshift-release-dev/ocp-release (2)
- mirrors:
- mirror.registry.com:443/ocp/release
source: quay.io/openshift-release-dev/ocp-v4.0-art-dev
1 | 指定镜像镜像注册表和存储库的名称。 |
2 | 指定包含镜像内容的联机注册表和存储库。 |
创建新对象。
$ oc create -f registryrepomirror.yaml
创建对象后,机器配置操作员 (MCO) 仅会为ImageTagMirrorSet
对象排空节点。MCO不会为ImageDigestMirrorSet
和ImageContentSourcePolicy
对象排空节点。
要检查是否应用了镜像配置设置,请在一个节点上执行以下操作。
列出您的节点。
$ oc get node
NAME STATUS ROLES AGE VERSION
ip-10-0-137-44.ec2.internal Ready worker 7m v1.30.3
ip-10-0-138-148.ec2.internal Ready master 11m v1.30.3
ip-10-0-139-122.ec2.internal Ready master 11m v1.30.3
ip-10-0-147-35.ec2.internal Ready worker 7m v1.30.3
ip-10-0-153-12.ec2.internal Ready worker 7m v1.30.3
ip-10-0-154-10.ec2.internal Ready master 11m v1.30.3
启动调试过程以访问节点。
$ oc debug node/ip-10-0-147-35.ec2.internal
Starting pod/ip-10-0-147-35ec2internal-debug ...
To use host binaries, run `chroot /host`
将根目录更改为/host
。
sh-4.2# chroot /host
检查/etc/containers/registries.conf
文件,以确保进行了更改。
sh-4.2# cat /etc/containers/registries.conf
以下输出表示应用了安装后镜像配置 CR 的registries.conf
文件。最后两个条目分别标记为digest-only
和tag-only
。
unqualified-search-registries = ["registry.access.redhat.com", "docker.io"]
short-name-mode = ""
[[registry]]
prefix = ""
location = "registry.access.redhat.com/ubi9/ubi-minimal" (1)
[[registry.mirror]]
location = "example.io/example/ubi-minimal" (2)
pull-from-mirror = "digest-only" (3)
[[registry.mirror]]
location = "example.com/example/ubi-minimal"
pull-from-mirror = "digest-only"
[[registry]]
prefix = ""
location = "registry.example.com"
[[registry.mirror]]
location = "mirror.example.net/registry-example-com"
pull-from-mirror = "digest-only"
[[registry]]
prefix = ""
location = "registry.example.com/example"
[[registry.mirror]]
location = "mirror.example.net"
pull-from-mirror = "digest-only"
[[registry]]
prefix = ""
location = "registry.example.com/example/myimage"
[[registry.mirror]]
location = "mirror.example.net/image"
pull-from-mirror = "digest-only"
[[registry]]
prefix = ""
location = "registry.example.com"
[[registry.mirror]]
location = "mirror.example.com"
pull-from-mirror = "digest-only"
[[registry]]
prefix = ""
location = "registry.example.com/redhat"
[[registry.mirror]]
location = "mirror.example.com/redhat"
pull-from-mirror = "digest-only"
[[registry]]
prefix = ""
location = "registry.access.redhat.com/ubi9/ubi-minimal"
blocked = true (4)
[[registry.mirror]]
location = "example.io/example/ubi-minimal-tag"
pull-from-mirror = "tag-only" (5)
1 | 指示在拉取规范中引用的存储库。 |
2 | 指示该存储库的镜像。 |
3 | 指示从镜像拉取镜像是摘要引用镜像。 |
4 | 指示为此存储库设置了NeverContactSource 参数。 |
5 | 指示从镜像拉取镜像是标签引用镜像。 |
将镜像从源拉取到节点,并检查镜像是否已解析。
sh-4.2# podman pull --log-level=debug registry.access.redhat.com/ubi9/ubi-minimal@sha256:5cf...
如果存储库镜像过程无法按描述工作,请使用以下关于存储库镜像工作方式的信息来帮助排除问题。
第一个可用的镜像用于提供拉取的镜像。
只有在其他镜像源都失效的情况下,才会使用主注册表。
从系统上下文中,Insecure
标志用作回退。
/etc/containers/registries.conf
文件的格式最近已更改。它现在是版本 2,采用 TOML 格式。
使用ImageContentSourcePolicy
(ICSP) 对象配置镜像仓库镜像是一个已弃用的功能。此功能仍在 Red Hat OpenShift Service on AWS 中包含并继续受支持;但是,它将在该产品的未来版本中删除,不建议在新的部署中使用。
ICSP 对象正在被ImageDigestMirrorSet
和 ImageTagMirrorSet
对象替换以配置镜像仓库镜像。如果您有用于创建ImageContentSourcePolicy
对象的现有 YAML 文件,则可以使用oc adm migrate icsp
命令将这些文件转换为ImageDigestMirrorSet
YAML 文件。该命令将 API 更新到当前版本,将kind
值更改为ImageDigestMirrorSet
,并将spec.repositoryDigestMirrors
更改为spec.imageDigestMirrors
。文件的其余部分保持不变。
由于迁移不会更改registries.conf
文件,因此集群不需要重启。
有关ImageDigestMirrorSet
或ImageTagMirrorSet
对象的更多信息,请参见上一节中的“配置镜像注册表镜像仓库”。
作为具有dedicated-admin
角色的用户访问集群。
确保您的集群上具有ImageContentSourcePolicy
对象。
使用以下命令将一个或多个ImageContentSourcePolicy
YAML 文件转换为ImageDigestMirrorSet
YAML 文件
$ oc adm migrate icsp <file_name>.yaml <file_name>.yaml <file_name>.yaml --dest-dir <path_to_the_directory>
其中
<file_name>
指定源ImageContentSourcePolicy
YAML 的名称。您可以列出多个文件名。
--dest-dir
可选:指定输出ImageDigestMirrorSet
YAML 的目录。如果未设置,则文件将写入当前目录。
例如,以下命令转换icsp.yaml
和icsp-2.yaml
文件并将新的 YAML 文件保存到idms-files
目录。
$ oc adm migrate icsp icsp.yaml icsp-2.yaml --dest-dir idms-files
wrote ImageDigestMirrorSet to idms-files/imagedigestmirrorset_ubi8repo.5911620242173376087.yaml
wrote ImageDigestMirrorSet to idms-files/imagedigestmirrorset_ubi9repo.6456931852378115011.yaml
运行以下命令创建 CR 对象
$ oc create -f <path_to_the_directory>/<file-name>.yaml
其中
<path_to_the_directory>
如果您使用了--dest-dir
标志,则指定目录的路径。
<file_name>
指定ImageDigestMirrorSet
YAML 的名称。
在 IDMS 对象推出后删除 ICSP 对象。