allowedRegistriesForImport
image.config.openshift.io/cluster
资源保存关于如何处理镜像的集群范围信息。规范且唯一有效的名称是 cluster
。它的 spec
提供以下配置参数。
诸如 |
参数 | 描述 |
---|---|
|
限制普通用户可以从中导入镜像的容器镜像注册表。将此列表设置为您信任的包含有效镜像的注册表,以及您希望应用程序能够从中导入镜像的注册表。拥有权限从 API 创建镜像或 此列表的每个元素都包含由注册表域名指定的注册表位置。
|
|
对包含在 此配置映射的命名空间是 |
|
提供默认外部镜像注册表的主机名。仅当镜像注册表在外部公开时才应设置外部主机名。第一个值用于 image stream 中的 |
|
包含确定容器运行时在访问构建和 Pod 的镜像时应如何处理各个注册表的配置。例如,是否允许不安全访问。它不包含内部集群注册表的配置。
可以设置 |
当定义 |
image.config.openshift.io/cluster
资源的 status
字段保存来自集群的观察值。
参数 | 描述 |
---|---|
|
由镜像注册表操作员设置,该操作员控制 |
|
由镜像注册表操作员设置,当镜像注册表在外部公开时,提供镜像注册表的外部主机名。第一个值用于 image stream 中的 |
您可以通过编辑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 :对包含在镜像流导入、Pod 镜像拉取、openshift-image-registry 透传和构建期间受信任的附加证书颁发机构 (CA) 的配置映射的引用。此配置映射的命名空间是openshift-config 。配置映射的格式是使用注册表主机名作为键,并将 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)。OpenShift Dedicated 将此 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 检测到更改时,它会排干节点,应用更改,然后取消隔离节点。节点返回到Ready
状态后,将使用允许的注册表列表更新每个节点上的/etc/containers/policy.json
文件中的镜像签名策略。
如果您的集群使用 例如
|
您可以通过编辑image.config.openshift.io/cluster
自定义资源 (CR) 来阻止任何注册表,以及可选的注册表中的单个存储库。OpenShift Dedicated 将此 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 检测到更改时,它会排干节点,应用更改,然后取消隔离节点。节点返回到Ready
状态后,对阻止注册表的更改将出现在每个节点上的/etc/containers/registries.conf
文件中。
您可以通过编辑image.config.openshift.io/cluster
自定义资源 (CR) 来添加不安全的注册表,以及可选的注册表中的单个存储库。OpenShift Dedicated 将此 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) 来添加用于搜索镜像短名称的注册表。OpenShift Dedicated 会将对该 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。
配置映射键是具有端口的注册表的主机名,为此 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
设置容器注册表镜像可以执行以下任务:
配置您的 OpenShift Dedicated 集群以重定向请求,以从源镜像注册表上的存储库拉取镜像,并使其由镜像镜像注册表上的存储库解析。
为每个目标存储库识别多个镜像存储库,以确保如果一个镜像宕机,则可以使用另一个镜像。
OpenShift Dedicated 中的存储库镜像包括以下属性:
镜像拉取能够应对注册表宕机。
断开连接的环境中的集群可以从关键位置(例如 quay.io)拉取镜像,并让公司防火墙后面的注册表提供请求的镜像。
发出镜像拉取请求时,会尝试按特定顺序尝试注册表,永久注册表通常是最后尝试的一个。
您输入的镜像信息将添加到 OpenShift Dedicated 集群中每个节点上的/etc/containers/registries.conf
文件中。
当节点从源存储库请求镜像时,它会依次尝试每个镜像存储库,直到找到请求的内容。如果所有镜像都失败,则集群会尝试源存储库。如果成功,则将镜像拉取到节点。
可以使用以下方法设置存储库镜像:
在 OpenShift Dedicated 安装期间
通过拉取 OpenShift Dedicated 所需的容器镜像,然后将这些镜像置于贵公司防火墙之后,您可以将 OpenShift Dedicated 安装到处于隔离环境的数据中心中。
在 OpenShift Dedicated 安装之后
如果您在 OpenShift Dedicated 安装期间未配置镜像,则可以在安装后使用以下任何自定义资源 (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
命令(如后面的**转换用于镜像注册表库镜像的 ImageContentSourcePolicy (ICSP) 文件**部分所示)将当前工作负载迁移到 IDMS 对象。迁移到 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
复制到该库。创建镜像注册表后,您可以配置 OpenShift Dedicated 集群以将对源库的请求重定向到镜像库。
创建安装后镜像配置 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) 对象配置仓库镜像是一个已弃用的功能。此功能仍包含在OpenShift Dedicated中,并将继续得到支持;但是,它将在此产品的未来版本中移除,不建议用于新的部署。
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对象。