3.16. 为容器镜像准备 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 身份验证”

步骤

  1. 创建所有容器镜像的列表:

    $ sudo podman search --limit 1000 "registry.redhat.io/rhosp-rhel8/openstack" --format="{{ .Name }}" | sort > satellite_images
    $ sudo podman search --limit 1000 "registry.redhat.io/rhceph" | grep rhceph-4-dashboard-rhel8
    $ sudo podman search --limit 1000 "registry.redhat.io/rhceph" | grep rhceph-4-rhel8
    $ sudo podman search --limit 1000 "registry.redhat.io/openshift" | grep ose-prometheus
    • 如果您计划安装 Ceph 并启用 Ceph 仪表板,则需要以下 ose-prometheus 容器:

      registry.redhat.io/openshift4/ose-prometheus-node-exporter:v4.6
      registry.redhat.io/openshift4/ose-prometheus:v4.6
      registry.redhat.io/openshift4/ose-prometheus-alertmanager:v4.6
  2. satellite_images 文件复制到包含 Satellite 6 hammer 工具的系统中。或者,根据 Hammer CLI 指南中的说明将 hammer 工具安装到 undercloud 中。
  3. 运行以下 hammer 命令在 Satellite 机构中创建新产品(OSP 容器):

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

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

  4. 添加 satellite_images 文件中的 overcloud 容器镜像:

    $ while read IMAGE; do \
      IMAGE_NAME=$(echo $IMAGE | cut -d"/" -f3 | sed "s/openstack-//g") ; \
      IMAGE_NOURL=$(echo $IMAGE | sed "s/registry.redhat.io\///g") ; \
      hammer repository create \
      --organization "ACME" \
      --product "OSP Containers" \
      --content-type docker \
      --url https://registry.redhat.io \
      --docker-upstream-name $IMAGE_NOURL \
      --upstream-username USERNAME \
      --upstream-password PASSWORD \
      --name $IMAGE_NAME ; done < satellite_images
  5. 添加 Ceph Storage 4 容器镜像:

    $ hammer repository create \
      --organization "ACME" \
      --product "OSP Containers" \
      --content-type docker \
      --url https://registry.redhat.io \
      --docker-upstream-name rhceph/rhceph-4-rhel8 \
      --upstream-username USERNAME \
      --upstream-password PASSWORD \
      --name rhceph-4-rhel8
    注意

    如果要安装 Ceph 仪表板,请在 hammer repository create 命令中包含 --name rhceph-4-dashboard-rhel8

    $ hammer repository create \
      --organization "ACME" \
      --product "OSP Containers" \
      --content-type docker \
      --url https://registry.redhat.io \
      --docker-upstream-name rhceph/rhceph-4-dashboard-rhel8 \
      --upstream-username USERNAME \
      --upstream-password PASSWORD \
      --name rhceph-4-dashboard-rhel8
  6. 同步容器镜像:

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

    等待 Satellite 服务器完成同步。

    注意

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

  7. 如果您的 Satellite 6 服务器使用内容视图,请创建一个用于纳入镜像的新内容视图版本,并在应用生命周期的不同环境之间推进这个视图。这在很大程度上取决于您如何构建应用程序的生命周期。例如,如果您的生命周期中有一个称为 production 的环境,并且希望容器镜像在该环境中可用,则创建一个包含容器镜像的内容视图,并将该内容视图推进到 production 环境中。有关更多信息,请参阅管理内容视图
  8. 检查 base 镜像的可用标签:

    $ hammer docker tag list --repository "base" \
      --organization "ACME" \
      --lifecycle-environment "production" \
      --product "OSP Containers"

    此命令显示内容视图中特定环境的 OpenStack Platform 容器镜像的标签。

  9. 返回到 undercloud,并生成默认的环境文件,它将您的 Satellite 服务器用作源来准备镜像。运行以下示例命令以生成环境文件:

    $ sudo openstack tripleo container image prepare default \
      --output-env-file containers-prepare-parameter.yaml
    • --output-env-file 是环境文件名称。此文件的内容包括用于为 undercloud 准备容器镜像的参数。在本例中,文件的名称是 containers-prepare-parameter.yaml
  10. 编辑 containers-prepare-parameter.yaml 文件并修改以下参数:

    • push_destination - 根据您选择的容器镜像管理策略,将此参数设置为 truefalse。如果将此参数设置为 false,则 overcloud 节点直接从 Satellite 拉取镜像。如果将此参数设置为 true,则 director 将镜像从 Satellite 拉取到 undercloud registry,overcloud 从 undercloud registry 拉取镜像。
    • namespace - Satellite 服务器上 registry 的 URL 和端口。Red Hat Satellite 上的默认 registry 端口为 443。
    • name_prefix - 该前缀基于 Satellite 6 规范。它的值根据您是否使用了内容视图而不同:

      • 如果您使用了内容视图,则前缀的结构为 [组织]-[环境]-[内容视图]-[产品]-。例如: acme-production-myosp16-osp_containers-
      • 如果不使用内容视图,则前缀的结构为 [组织]-[产品]-。例如: acme-osp_containers-
    • ceph_namespaceceph_imageceph_tag - 如果使用 Ceph Storage,请额外纳入这些参数以定义 Ceph Storage 容器镜像的位置。请注意,ceph_image 现包含特定于 Satellite 的前缀。这个前缀与 name_prefix 选项的值相同。

以下示例环境文件包含特定于 Satellite 的参数:

parameter_defaults:
  ContainerImagePrepare:
  - push_destination: false
    set:
      ceph_image: acme-production-myosp16_1-osp_containers-rhceph-4
      ceph_namespace: satellite.example.com:443
      ceph_tag: latest
      name_prefix: acme-production-myosp16_1-osp_containers-
      name_suffix: ''
      namespace: satellite.example.com:443
      neutron_driver: null
      tag: '16.2'
      ...
注意

要使用存储在 Red Hat Satellite Server 上的特定容器镜像版本,请将 标签 键值对设置为 set 字典中的特定版本。例如,要使用 16.2.2 镜像流,请在 set 字典中设置 tag: 16.2.2

您必须在 undercloud.conf 配置文件中定义 containers-prepare-parameter.yaml 环境文件,否则 undercloud 将使用默认值:

container_images_file = /home/stack/containers-prepare-parameter.yaml