4.9.6. 更新索引镜像

在将 OperatorHub 配置为使用引用自定义索引镜像的目录源后,集群管理员可通过将捆绑包镜像添加到索引镜像来保持其集群上的可用 Operator 最新状态。

您可以使用 opm index add 命令来更新存在的索引镜像。对于受限网络,还必须将更新的内容重新镜像到集群。

先决条件

  • opm 版本 1.12.3+
  • podman 版本 1.9.3+
  • 构建并推送到 registry 的索引镜像。
  • 引用索引镜像的现有目录源。

流程

  1. 通过添加捆绑包镜像来更新现有索引:

    $ opm index add \
        --bundles <registry>/<namespace>/<new_bundle_image>@sha256:<digest> \1
        --from-index <registry>/<namespace>/<existing_index_image>:<existing_tag> \2
        --tag <registry>/<namespace>/<existing_index_image>:<updated_tag> \3
        --pull-tool podman 4
    1
    --bundles 标志指定要添加到索引中的、以逗号分隔的额外捆绑包镜像列表。
    2
    --from-index 标志指定之前推送的索引。
    3
    --tag 标志指定要应用到更新的索引镜像的镜像标签。
    4
    --pull-tool 标志指定用于拉取容器镜像的工具。

    其中:

    <registry>
    指定 registry 的主机名,如 quay.iomirror.example.com
    <namespace>
    指定 registry 的命名空间,如 ocs-devabc
    <new_bundle_image>
    指定要添加到 registry 的新捆绑包镜像,如 ocs-operator
    <digest>
    指定捆绑包镜像的 SHA 镜像 ID 或摘要,如 c7f11097a628f092d8bad148406aa0e0951094a03445fd4bc0775431ef683a41
    <existing_index_image>
    指定之前推送的镜像,如 abc-redhat-operator-index
    <existing_tag>
    指定之前推送的镜像标签,如 4.7
    <updated_tag>
    指定要应用到更新的索引镜像的镜像标签,如 4.7.1

    示例命令

    $ opm index add \
        --bundles quay.io/ocs-dev/ocs-operator@sha256:c7f11097a628f092d8bad148406aa0e0951094a03445fd4bc0775431ef683a41 \
        --from-index mirror.example.com/abc/abc-redhat-operator-index:4.7 \
        --tag mirror.example.com/abc/abc-redhat-operator-index:4.7.1 \
        --pull-tool podman

  2. 推送更新的索引镜像:

    $ podman push <registry>/<namespace>/<existing_index_image>:<updated_tag>
  3. 按照镜像 Operator 目录流程中的步骤来镜像更新的内容。但是,当进入创建 ImageContentSourcePolicy(ICSP)对象的步骤时,请使用 oc replace 命令而不是 oc create 命令。例如:

    $ oc replace -f ./manifests-redhat-operator-index-<random_number>/imageContentSourcePolicy.yaml

    这一更改是必需的,因为对象已存在且必须更新。

    注意

    通常,oc apply 命令可用于更新之前使用 oc apply 创建的现有对象。但是,由于有关 ICSP 对象中的 metadata.annotations 字段大小的已知问题,oc replace 命令当前必须用于此步骤。

  4. Operator Lifecycle Manager(OLM)会在常规时间段内自动轮询目录源中引用的索引镜像,验证是否已成功添加新软件包:

    $ oc get packagemanifests -n openshift-marketplace