Red Hat Training

A Red Hat training course is available for Red Hat OpenStack Platform

2.6. 将 Satellite 服务器用作 registry

Red Hat Satellite 6 提供了注册表同步功能。通过该功能可将多个镜像提取到 Satellite 服务器中,作为应用程序生命周期的一部分加以管理。Satellite 也可以作为 registry 供其他启用容器功能的系统使用。有关管理容器镜像的更多信息,请参阅 Red Hat Satellite 6 内容管理指南中的“管理容器镜像”

以下操作过程示例中使用了 Red Hat Satellite 6 的 hammer 命令行工具和一个名为 ACME 的示例组织。请将该组织替换为您自己 Satellite 6 中的组织。

流程

  1. 创建模板以将镜像拉取到本地 registry:

    $ source ~/stackrc
    (undercloud) $ openstack overcloud container image prepare \
      --namespace=rhosp13 \
      --prefix=openstack- \
      --output-images-file /home/stack/satellite_images
    • 使用 -e 选项包括可选服务的任何环境文件。
    • 使用 -r 选项包含自定义角色文件。
    • 如果使用 Ceph Storage,请包含额外的参数来定义 Ceph Storage 容器镜像位置:-- set ceph_namespace ,--set ceph _image,--set ceph_tag
    注意

    此版本的 openstack overcloud container image prepare 命令以 registry 上的 registry 为目标,以生成镜像列表。它使用与后续步骤中使用的 openstack overcloud container image prepare 命令不同的值。

  2. 这会创建一个名为 satellite_images 的文件,以及您的容器镜像信息。您将使用此文件将容器镜像同步到 Satellite 6 服务器。
  3. satellite_images 文件中删除 YAML 特定信息,并将其转换为仅包含镜像列表的平面文件。以下 sed 命令完成此操作:

    (undercloud) $ awk -F ':' '{if (NR!=1) {gsub("[[:space:]]", ""); print $2}}' ~/satellite_images > ~/satellite_images_names

    这提供了您拉取到 Satellite 服务器的镜像列表。

  4. satellite_images_names 文件复制到包含 Satellite 6 hammer 工具的系统中。或者,根据 Hammer CLI 指南中的说明将 hammer 工具安装到 undercloud 中。
  5. 运行以下 hammer 命令,为您的 Satellite 组织创建新产品(OSP13 容器):

    $ hammer product create \
      --organization "ACME" \
      --name "OSP13 Containers"

    该定制产品将会包含我们的镜像。

  6. 为产品添加基本容器镜像:

    $ hammer repository create \
      --organization "ACME" \
      --product "OSP13 Containers" \
      --content-type docker \
      --url https://registry.redhat.io \
      --docker-upstream-name rhosp13/openstack-base \
      --name base
  7. 添加 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 "OSP13 Containers" \
      --content-type docker \
      --url https://registry.redhat.io \
      --docker-upstream-name $IMAGE \
      --name $IMAGENAME ; done < satellite_images_names
  8. 同步容器镜像:

    $ hammer product synchronize \
      --organization "ACME" \
      --name "OSP13 Containers"

    等待 Satellite 服务器完成同步。

    注意

    根据具体配置情况,hammer 可能会询问您的 Satellite 服务器用户名和密码。您可以使用配置文件将 hammer 配置为自动登录。请参阅 Hammer CLI 指南中的 "身份验证" 部分。

  9. 如果您的 Satellite 6 服务器使用内容视图,请创建一个新的内容视图版本来包含镜像。
  10. 检查可用于 基础镜像 的标签:

    $ hammer docker tag list --repository "base" \
      --organization "ACME" \
      --product "OSP13 Containers"

    这将显示 OpenStack Platform 容器镜像的标签。

  11. 返回到 undercloud,再为卫星服务器上的镜像生成环境文件。以下是生成环境文件的示例命令:

    (undercloud) $ openstack overcloud container image prepare \
      --namespace=satellite6.example.com:5000 \
      --prefix=acme-osp13_containers- \
      --tag-from-label {version}-{release} \
      --output-env-file=/home/stack/templates/overcloud_images.yaml
    注意

    此版本的 openstack overcloud container image prepare 命令以 Satellite 服务器为目标。它使用与上一步中使用的 openstack overcloud container image prepare 命令不同的值。

    在运行这个命令时,包括以下数据:

    • --namespace - Satellite 服务器上 registry 的 URL 和端口。Red Hat Satellite 上的 registry 端口是 5000。例如,-- namespace=satellite6.example.com:5000

      注意

      如果您使用 Red Hat Satellite 版本 6.10,则不需要指定端口。使用 443 的默认端口。如需更多信息,请参阅 "如何将 RHOSP13 部署到 Red Hat Satellite 6.10?"

    • --prefix= - 前缀基于标签的 Satellite 6 约定,它使用小写字符并替换下划线的空格。根据您是否使用内容视图,前缀会有所不同:

      • 如果您使用了内容视图,则前缀的结构为 [组织]-[环境]-[内容视图]-[产品]-。例如: acme-production-myosp13-osp13_containers-
      • 如果不使用内容视图,则前缀的结构为 [组织]-[产品]-。例如: acme-osp13_containers-
    • --tag-from-label {version}-{release} - 标识每个镜像的 latest 标签。
    • -e - 包含任何用于可选服务的环境文件。
    • -r - 包含自定义角色文件。
    • --set ceph_namespace,--set ceph_image,--set ceph_tag - 如果使用 Ceph Storage,请包含额外的参数来定义 Ceph Storage 容器镜像位置。请注意,ceph_image 现包含特定于 Satellite 的前缀。这个前缀与 --prefix 选项的值相同。例如:

      --set ceph_image=acme-osp13_containers-rhceph-3-rhel7

      这可确保 overcloud 使用采用卫星命名约定的 Ceph 容器镜像。

  12. overcloud_images.yaml 文件包含 Satellite 服务器上的镜像位置。将此文件与您的部署一起包含。

registry 配置已就绪。