第 27 章 执行高级容器镜像管理

默认容器镜像配置适合大多数环境。在某些情况下,您的容器镜像配置可能需要一些自定义,如版本固定。

27.1. 为 undercloud 固定容器镜像

在某些情况下,您可能需要 undercloud 的一组特定容器镜像版本。在这种情况下,您必须将镜像固定到特定的版本。要固定镜像,您必须生成和修改容器配置文件,然后将 undercloud 角色数据和容器配置文件结合,以生成包含服务到容器镜像映射的环境文件。在 undercloud.conf 文件的 custom_env_files 参数中包含此环境文件。

步骤

  1. stack 用户身份登录 undercloud 主机。
  2. 使用 --output-env-file 选项运行 openstack tripleo container image prepare default 命令,生成包含默认镜像配置的文件:

    $ sudo openstack tripleo container image prepare default \
    --output-env-file undercloud-container-image-prepare.yaml
  3. 根据您的环境要求,修改 undercloud-container-image-prepare.yaml 文件。

    1. 移除 tag: 参数,以便 director 可以使用 tag_from_label: 参数。director 使用此参数来标识每个容器镜像的最新版本,拉取每个镜像,并在 director 中的容器 registry 上标记每个镜像。
    2. 移除 undercloud 的 Ceph 标签。
    3. 确保 neutron_driver: 参数为空。不要将此参数设置为 OVN,因为 undercloud 不支持 OVN。
    4. 包含容器镜像 registry 凭据:

      ContainerImageRegistryCredentials:
        registry.redhat.io
          myser: 'p@55w0rd!'
      注意

      您无法将容器镜像推送到新 undercloud 上的 undercloud registry,因为 image-serve registry 尚未安装。您必须将 push_destination 值设置为 false,或使用自定义值直接从源拉取镜像。有关更多信息,请参阅容器镜像准备参数

  4. 生成新的容器镜像配置文件,该文件结合使用 undercloud 角色文件和自定义 undercloud-container-image-prepare.yaml 文件:

    $ sudo openstack tripleo container image prepare \
    -r /usr/share/openstack-tripleo-heat-templates/roles_data_undercloud.yaml \
    -e undercloud-container-image-prepare.yaml \
    --output-env-file undercloud-container-images.yaml

    undercloud-container-images.yaml 文件是一个环境文件,包含服务参数到容器镜像的映射。例如,OpenStack Identity (keystone) 使用 ContainerKeystoneImage 参数来定义其容器镜像:

    ContainerKeystoneImage: undercloud.ctlplane.localdomain:8787/rhosp-rhel8/openstack-keystone:16.2.4-5

    请注意,容器镜像标签与 {version}-{release} 格式匹配。

  5. undercloud-container-images.yaml 文件包含在 undercloud.conf 文件的 custom_env_files 参数中。在运行 undercloud 安装时,undercloud 服务使用来自此文件的固定容器镜像映射。