2.4. 镜像 OpenShift Container Platform 镜像存储库

镜像要在集群安装或升级过程中使用的 OpenShift Container Platform 镜像存储库。

先决条件

  • 您已将镜像 registry 配置为在受限网络中使用,并可访问您配置的证书和凭证。
  • 您已从 Red Hat OpenShift Cluster Manager 站点的 Pull Secret页面下载了 pull secret,并已修改为包含镜像存储库身份验证信息。

流程

在堡垒主机上完成以下步骤:

  1. 查看 OpenShift Container Platform 下载页面,以确定您要安装的 OpenShift Container Platform 版本。
  2. 设置所需的环境变量:

    $ export OCP_RELEASE=<release_version> 1
    $ export LOCAL_REGISTRY='<local_registry_host_name>:<local_registry_host_port>' 2
    $ export LOCAL_REPOSITORY='<repository_name>' 3
    $ export PRODUCT_REPO='openshift-release-dev' 4
    $ export LOCAL_SECRET_JSON='<path_to_pull_secret>' 5
    $ export RELEASE_NAME="ocp-release" 6
    1
    对于 <release_version>,请指定要安装的 OpenShift Container Platform 版本号,如 4.2.0
    2
    对于 <local_registry_host_name>,请指定镜像存储库的 registry 域名;对于 <local_registry_host_port>,请指定用于提供内容的端口。
    3
    对于 <repository_name>,请指定要在 registry 中创建的存储库名称,如 ocp4/openshift4
    4
    要镜像的存储库。对于生产环境版本,必须指定 openshift-release-dev
    5
    对于 <path_to_pull_secret>,请指定您创建的镜像 registry 的 pull secret 的绝对路径和文件名。
    6
    发行版本镜像。对于生产环境版本,您必须指定 ocp-release
  3. 镜像存储库:

    $ oc adm -a ${LOCAL_SECRET_JSON} release mirror \
         --from=quay.io/${PRODUCT_REPO}/${RELEASE_NAME}:${OCP_RELEASE} \
         --to=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY} \
         --to-release-image=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}

    该命令将发行信息提取为摘要,其输出包括安装集群时所需的 imageContentSources 数据。

  4. 记录上一命令输出中的 imageContentSources 部分。您的镜像信息与您的镜像存储库相对应,您必须在安装过程中将 imageContentSources 部分添加到 install-config.yaml 文件中。
  5. 要创建基于您镜像内容的安装程序,请提取内容并将其固定到发行版中:

    $ oc adm -a ${LOCAL_SECRET_JSON} release extract --command=openshift-install "${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}"
    重要

    要确保将正确的镜像用于您选择的 OpenShift Container Platform 版本,您必须从镜像内容中提取安装程序。

    您必须在有活跃互联网连接的机器上执行这个步骤。