3.11. 为容器镜像准备 Satellite 服务器
Red Hat Satellite 6 提供了注册表同步功能。通过该功能可将多个镜像提取到 Satellite 服务器中,作为应用程序生命周期的一部分加以管理。Satellite 也可以作为 registry 供其他启用容器功能的系统使用。有关管理容器镜像的更多信息,请参阅 Red Hat Satellite 6 内容管理指南中的“管理容器镜像”。
以下操作过程示例中使用了 Red Hat Satellite 6 的 hammer
命令行工具和一个名为 ACME
的示例组织。请将该组织替换为您自己 Satellite 6 中的组织。
此过程需要身份验证凭据以从 registry.redhat.io
访问容器镜像。红帽建议创建一个 registry 服务帐户并使用这些凭据访问 registry.redhat.io
内容,而不使用您的个人用户凭据。有关更多信息,请参阅“红帽容器 registry 身份验证”。
步骤
创建所有容器镜像的列表:
$ sudo podman search --limit 1000 "registry.redhat.io/rhosp15-rhel8" | awk '{ print $2 }' | grep -v beta | sed "s/registry.redhat.io\///g" | tail -n+2 > satellite_images
-
将
satellite_images_names
文件复制到包含 Satellite 6hammer
工具的系统中。或者,根据 Hammer CLI 指南中的说明将hammer
工具安装到 undercloud 中。 运行以下
hammer
命令以在 Satellite 组织中创建新产品(OSP15 容器
):$ hammer product create \ --organization "ACME" \ --name "OSP15 Containers"
该定制产品将会包含我们的镜像。
为产品添加基本容器镜像:
$ hammer repository create \ --organization "ACME" \ --product "OSP15 Containers" \ --content-type docker \ --url https://registry.redhat.io \ --docker-upstream-name rhosp15-rhel8/openstack-base \ --upstream-username USERNAME \ --upstream-password PASSWORD \ --name base
添加
satellite_images
文件中的 overcloud 容器镜像。$ while read IMAGE; do \ IMAGENAME=$(echo $IMAGE | cut -d"/" -f2 | sed "s/openstack-//g" | sed "s/:.*//g") ; \ hammer repository create \ --organization "ACME" \ --product "OSP15 Containers" \ --content-type docker \ --url https://registry.redhat.io \ --docker-upstream-name $IMAGE \ --upstream-username USERNAME \ --upstream-password PASSWORD \ --name $IMAGENAME ; done < satellite_images_names
添加 Ceph Storage 4 容器镜像:
$ hammer repository create \ --organization "ACME" \ --product "OSP15 Containers" \ --content-type docker \ --url https://registry.redhat.io \ --docker-upstream-name rhceph-beta/rhceph-4-rhel8 \ --upstream-username USERNAME \ --upstream-password PASSWORD \ --name rhceph-4-rhel8
同步容器镜像:
$ hammer product synchronize \ --organization "ACME" \ --name "OSP15 Containers"
等待 Satellite 服务器完成同步。
注意根据具体配置情况,
hammer
可能会询问您的 Satellite 服务器用户名和密码。您可以使用配置文件将hammer
配置为自动登录。有关更多信息,请参阅 Hammer CLI 指南中的“身份验证”章节。-
如果您的 Satellite 6 服务器使用内容视图,请创建一个用于纳入镜像的新内容视图版本,并在应用生命周期的不同环境之间推进这个视图。这在很大程度上取决于您如何构建应用程序的生命周期。例如,如果您的生命周期中有一个称为
production
的环境,并且希望容器镜像在该环境中可用,则创建一个包含容器镜像的内容视图,并将该内容视图推进到production
环境中。有关更多信息,请参阅“使用内容视图管理容器镜像”。 检查
base
镜像的可用标签:$ hammer docker tag list --repository "base" \ --organization "ACME" \ --environment "production" \ --content-view "myosp15" \ --product "OSP15 Containers"
此命令显示内容视图中特定环境的 OpenStack Platform 容器镜像的标签。
返回到 undercloud,并生成默认的环境文件(将您的 Satellite 服务器用作源来准备镜像)。运行以下示例命令以生成环境文件:
(undercloud) $ openstack tripleo container image prepare default \ --output-env-file containers-prepare-parameter.yaml
-
--output-env-file
是环境文件名称。此文件的内容包括用于为 undercloud 准备容器镜像的参数。在本例中,文件的名称是containers-prepare-parameter.yaml
。
-
编辑
containers-prepare-parameter.yaml
文件并修改以下参数:-
namespace
- Satellite 服务器上注册表的 URL 和端口。Red Hat Satellite 上的默认注册表端口是 5000。 name_prefix
- 该前缀基于 Satellite 6 规范。它的值根据您是否使用了内容视图而不同:-
如果您使用了内容视图,则前缀的结构为
[组织]-[环境]-[内容视图]-[产品]-
。例如:acme-production-myosp15-osp15_containers-
。 -
如果不使用内容视图,则前缀的结构为
[组织]-[产品]-
。例如:acme-osp15_containers-
。
-
如果您使用了内容视图,则前缀的结构为
-
ceph_namespace
、ceph_image
、ceph_tag
- 如果正在使用 Ceph Storage,请额外纳入这些参数以定义 Ceph Storage 容器镜像的位置。请注意,ceph_image
现包含特定于 Satellite 的前缀。这个前缀与name_prefix
选项的值相同。
-
以下示例环境文件包含特定于 Satellite 的参数:
parameter_defaults: ContainerImagePrepare: - push_destination: true set: ceph_image: acme-production-myosp15-osp15_containers-rhceph-4 ceph_namespace: satellite.example.com:5000 ceph_tag: latest name_prefix: acme-production-myosp15-osp15_containers- name_suffix: '' namespace: satellite.example.com:5000 neutron_driver: null tag: latest ... tag_from_label: '{version}-{release}'
在创建 undercloud 和 overcloud 时使用此环境文件。