9.4. Red Hat OpenShift Service on AWS 的镜像 registry 镜像
您可以使用 ImageDigestMirrorSet (IDMS) 对象配置现有 Red Hat OpenShift Service on AWS 集群来从镜像 registry 中拉取镜像。
镜像镜像配置功能只按摘要运行镜像引用,这意味着镜像镜像仅在使用其唯一和不可变 ID 拉取镜像时激活。目前,此功能不支持使用 mutable 标签的任何镜像引用。
IDMS 为 registry 镜像定义一组集群范围的策略,使镜像下载更快、更可靠且更安全。它的工作原理是拦截通过其唯一、可寻址的摘要识别镜像的任何镜像拉取请求。根据这些策略,IDMS 透明地将 pull 操作从指定源 registry 重定向到一个或多个指定的镜像 registry。对于开发人员,这意味着其请求 - 指向原始源,自动由更接近的镜像实现,从而显著提高部署速度,而无需对其工作流进行任何更改。
先决条件
要配置现有的 Red Hat OpenShift Service on AWS 集群,以使用 ImageDigestMirrorSet (IDMS) 对象从镜像 registry 中拉取镜像,您必须满足以下先决条件:
-
您已在安装主机上安装和配置了最新的 ROSA 命令行界面(CLI) (
rosa)。 - 您已在 AWS 集群上安装了 Red Hat OpenShift Service。
- Red Hat OpenShift Service on AWS 集群必须处于 Ready 状态才能创建、编辑、列出或删除镜像镜像。
- 您可以访问您要配置的镜像 registry。
- 您有管理集群配置所需的 IAM 权限。如需更多信息,请参阅附加资源部分中的"关于 IAM 资源 "。
将 Red Hat OpenShift Service on AWS 集群配置为使用 IDMS 从已镜像的 registry 中拉取镜像的好处包括:
- 增强的安全 :通过强制从私有镜像 registry 中拉取(pull)镜像,您可以在进入集群前扫描并批准所有漏洞的镜像。
- 改进了集群可靠性 :本地镜像通过消除对公共互联网路径的依赖来保证稳定且可预测的集群性能。
- 保证镜像一致性 :IDMS 使用镜像摘要来引用镜像,这样可确保集群中的每个节点拉取相同的镜像版本,防止可能导致部署失败的不一致。
9.4.1. 创建镜像镜像配置 复制链接链接已复制到粘贴板!
流程
要为 Red Hat OpenShift Service on AWS 集群创建镜像镜像配置,请运行以下命令:
源 registry 创建后无法修改。您必须删除并重新创建镜像以更改源。
语法
rosa create image-mirror [arguments]
$ rosa create image-mirror [arguments]
| 选项 | 定义 |
|---|---|
| --cluster | 必需:镜像配置要应用到的集群的名称或 ID。 |
| --source | 必需:要镜像的源 registry。 |
| --mirrors | 必需:镜像 registry 列表。镜像 registry 必须用逗号分开。 |
| --type=digest |
可选:镜像镜像的类型。默认情况下会设置 |
| --profile | 可选:指定来自您的凭证文件中的 AWS 配置集(字符串)。 |
| --region | 可选:指定 AWS 区域,覆盖 AWS_REGION 环境变量。 |
例子
为名为 mycluster 的集群创建镜像镜像配置。
rosa create image-mirror --cluster=mycluster \ --source=registry.example.com/team \ --mirrors=mirror.corp.com/team,backup.corp.com/team
$ rosa create image-mirror --cluster=mycluster \
--source=registry.example.com/team \
--mirrors=mirror.corp.com/team,backup.corp.com/team
输出示例
I: Image mirror with ID 'abc123def456' has been created on cluster 'mycluster' I: Source: registry.example.com/team I: Mirrors: [mirror.corp.com/team backup.corp.com/team]
I: Image mirror with ID 'abc123def456' has been created on cluster 'mycluster'
I: Source: registry.example.com/team
I: Mirrors: [mirror.corp.com/team backup.corp.com/team]
在镜像镜像配置创建过程中自动生成并分配给镜像镜像。
使用特定类型的镜像镜像配置。
默认情况下会设置 摘要 类型,以及唯一可用的 类型 选项。
rosa create image-mirror --cluster=mycluster \ --type=digest --source=docker.io/library \ --mirrors=internal-registry.company.com/dockerhub
$ rosa create image-mirror --cluster=mycluster \
--type=digest --source=docker.io/library \
--mirrors=internal-registry.company.com/dockerhub
使用集群的多个镜像创建单个镜像镜像配置。
rosa create image-mirror --cluster=mycluster \ --source=quay.io/openshift \ --mirrors=mirror1.company.com/openshift,mirror2.company.com/openshift,mirror3.company.com/openshift
$ rosa create image-mirror --cluster=mycluster \
--source=quay.io/openshift \
--mirrors=mirror1.company.com/openshift,mirror2.company.com/openshift,mirror3.company.com/openshift
9.4.2. 编辑镜像镜像配置 复制链接链接已复制到粘贴板!
流程
要编辑 Red Hat OpenShift Service on AWS 集群的镜像镜像配置,请运行以下命令:
在编辑镜像镜像配置时,新镜像列表会完全替换现有的 mirrors 列表。
语法
rosa edit image-mirror [arguments]
$ rosa edit image-mirror [arguments]
| 选项 | 定义 |
|---|---|
| --cluster | 必需:镜像镜像配置应用到的集群的名称或 ID (字符串)。 |
| --mirrors | 必需:替换当前镜像 registry 的镜像 registry 的新列表。镜像 registry 必须用逗号分开。 |
| --id | 必需:要编辑的镜像配置的 ID。 |
| --profile | 可选:使用凭证文件中的特定 AWS 配置集。 |
| --region | 可选:使用特定的 AWS 区域,覆盖 AWS_REGION 环境变量。 |
例子
替换镜像镜像配置上的单个镜像。
rosa edit image-mirror --cluster=mycluster --id=abc123def456 \ --mirrors=single-mirror.company.com/team
$ rosa edit image-mirror --cluster=mycluster --id=abc123def456 \
--mirrors=single-mirror.company.com/team
输出示例
I: Image mirror 'abc123def456' has been updated on cluster 'mycluster' I: Source: registry.example.com/team I: Updated mirrors: [mirror.corp.com/team backup.corp.com/team new-mirror.corp.com/team]
I: Image mirror 'abc123def456' has been updated on cluster 'mycluster'
I: Source: registry.example.com/team
I: Updated mirrors: [mirror.corp.com/team backup.corp.com/team new-mirror.corp.com/team]
替换镜像镜像配置中的所有镜像。
rosa edit image-mirror --cluster=mycluster --id=abc123def456 \ --mirrors=new-primary.company.com/team,new-secondary.company.com/team
$ rosa edit image-mirror --cluster=mycluster --id=abc123def456 \
--mirrors=new-primary.company.com/team,new-secondary.company.com/team
9.4.3. 列出所有镜像镜像配置 复制链接链接已复制到粘贴板!
流程
要列出 Red Hat OpenShift Service on AWS 集群的所有镜像镜像配置,请运行以下命令:
语法
rosa list image-mirrors [arguments]
$ rosa list image-mirrors [arguments]
| 选项 | 定义 |
|---|---|
| --cluster | 必需:集群的名称或 ID。 |
| --output |
可选:输出格式。允许的格式有 |
| --profile | 可选:使用凭证文件中的特定 AWS 配置集。 |
| --region | 可选:使用特定的 AWS 区域,覆盖 AWS_REGION 环境变量。 |
示例
列出集群的所有镜像镜像配置。
rosa list image-mirrors --cluster=mycluster
$ rosa list image-mirrors --cluster=mycluster
输出示例
ID TYPE SOURCE MIRRORS abc123def456 digest registry.example.com/team mirror.corp.com/team, backup.corp.com/
ID TYPE SOURCE MIRRORS
abc123def456 digest registry.example.com/team mirror.corp.com/team, backup.corp.com/
9.4.4. 删除镜像镜像配置 复制链接链接已复制到粘贴板!
删除操作需要确认,除非使用了-- yes 或-- y 参数。
流程
要从 Red Hat OpenShift Service on AWS 集群中删除镜像镜像配置,请运行以下命令:
语法
rosa delete image-mirror [arguments]
$ rosa delete image-mirror [arguments]
| 选项 | 定义 |
|---|---|
| --cluster | 必需:从中删除镜像配置的集群的名称或 ID (字符串)。 |
| --id | 必需:要删除的镜像镜像的 ID。 |
|
| 可选:自动回答 "yes" 以确认删除。 |
| --profile | 可选:使用凭证文件中的特定 AWS 配置集。 |
| --region | 可选:使用特定的 AWS 区域,覆盖 AWS_REGION 环境变量。 |
例子
在没有确认提示的情况下删除镜像镜像配置。
rosa delete image-mirror --cluster=mycluster abc123def456 --yes
$ rosa delete image-mirror --cluster=mycluster abc123def456 --yes
输出示例
I: Image mirror 'abc123def456' has been deleted from cluster 'mycluster'
I: Image mirror 'abc123def456' has been deleted from cluster 'mycluster'
通过确认提示删除镜像镜像配置。
rosa delete image-mirror --cluster=mycluster --id=abc123def456
$ rosa delete image-mirror --cluster=mycluster --id=abc123def456