8.3. Creating custom catalogs using the oc-mirror plugin


You can create custom catalogs with widely available Operators and mirror them by using the oc-mirror OpenShift CLI (oc) plugin.

8.3.1. Using Red Hat-provided Operator catalogs and mirror registries

You can filter and prune catalogs to get specific Operators and mirror them by using the oc-mirror OpenShift CLI (oc) plugin. You can also use Operators in disconnected settings or embedded in Red Hat Enterprise Linux for Edge (RHEL for Edge) images. To read more details about how to configure your systems for mirroring, use the links in the following "Additional resources" section. If you are ready to deploy Operators from Red Hat-provided Operator catalogs, mirror them, or to embed them in RHEL for Edge images, start with the following section, "Inspecting catalog contents by using the oc-mirror plugin."

8.3.2. About the oc-mirror plugin for creating a mirror registry

You can use the oc-mirror OpenShift CLI (oc) plugin with MicroShift to filter and prune Operator catalogs. You can then mirror the filtered catalog contents to a mirror registry or use the container images in disconnected or offline deployments with RHEL for Edge.

注記

MicroShift uses the generally available version (1) of the oc-mirror plugin. Do not use the following procedures with the Technical Preview version (2) of oc-mirror plugin.

You can mirror the container images required by the desired Operators locally or to a container mirror registry that supports Docker v2-2, such as Red Hat Quay. The procedure to mirror content from Red Hat-hosted registries connected to the internet to a disconnected image registry is the same, independent of the registry you choose. After you mirror the contents of your catalog, configure each cluster to retrieve this content from your mirror registry.

8.3.2.1. Connectivity considerations when populating a mirror registry

When you populate your registry, you can use one of following connectivity scenarios:

Connected mirroring
If you have a host that can access both the internet and your mirror registry, but not your cluster node, you can directly mirror the content from that machine.
Disconnected mirroring

If you do not have a host that can access both the internet and your mirror registry, you must mirror the images to a file system and then bring that host or removable media into your disconnected environment.

重要

A container registry must be reachable by every machine in the clusters that you provision. Installing, updating, and other operations, such as relocating workloads, might fail if the registry is unreachable.

To avoid problems caused by an unreachable registry, use the following standard practices:

  • Run mirror registries in a highly available way.
  • Ensure that the mirror registry at least matches the production availability of your clusters.

8.3.2.2. Inspecting catalog contents by using the oc-mirror plugin

Use the following example procedure to select a catalog and list Operators from available OpenShift Container Platform content to add to your oc-mirror plugin image set configuration file.

注記

If you use your own catalogs and Operators, you can push the images directly to your internal registry.

Prerequisites

  • The OpenShift CLI (oc) is installed.
  • Operator Lifecycle Manager (OLM) is installed.
  • The oc-mirror OpenShift CLI (oc) plugin is installed.

Procedure

  1. Get a list of available Red Hat-provided Operator catalogs to filter by running the following command:

    $ oc mirror list operators --version 4.17 --catalogs
  2. Get a list of Operators in the Red Hat Operators catalog by running the following command:

    $ oc mirror list operators <--catalog=<catalog_source>> 
    1
    1
    Specifies your catalog source, such as registry.redhat.io/redhat/redhat-operator-index:v4.17 or quay.io/operatorhubio/catalog:latest.
  3. Select an Operator. For this example, amq-broker-rhel8 is selected.
  4. Optional: To inspect the channels and versions of the Operator you want to filter, enter the following commands:

    1. Get a list of channels by running the following command:

      $ oc mirror list operators --catalog=registry.redhat.io/redhat/redhat-operator-index:v4.17 --package=amq-broker-rhel8
    2. Get a list of versions within a channel by running the following command:

      $ oc mirror list operators --catalog=registry.redhat.io/redhat/redhat-operator-index:v4.17 --package=amq-broker-rhel8 --channel=7.11.x

Next steps

  • Create and edit an image set configuration file using the information gathered in this procedure.
  • Mirror the images from the transformed image set configuration file to a mirror registry or disk.

8.3.2.3. Creating an image set configuration file

You must create an image set configuration file to mirror catalog contents with the oc-mirror plugin. The image set configuration file defines which Operators to mirror along with other configuration settings for the oc-mirror plugin. After generating a default image set file, you must edit the contents so that remaining entries are compatible with both MicroShift and the Operator you plan to use.

You must specify a storage backend in the image set configuration file. This storage backend can be a local directory or a registry that supports Docker v2-2. The oc-mirror plugin stores metadata in this storage backend during image set creation.

重要

Do not delete or modify the metadata that is generated by the oc-mirror plugin. You must use the same storage backend every time you run the oc-mirror plugin for the same mirror registry.

Prerequisites

Procedure

  1. Use the oc mirror init command to create a template for the image set configuration and save it to a file called imageset-config.yaml:

    $ oc mirror init --registry <storage_backend> > imageset-config.yaml 
    1
    1
    Specifies the location of your storage backend, such as example.com/mirror/oc-mirror-metadata.

    Example default image set configuration file

    kind: ImageSetConfiguration
    apiVersion: mirror.openshift.io/v1alpha2
    storageConfig:
      registry:
        imageURL: registry.example.com/oc-mirror
        skipTLS: false
    mirror:
      platform: 
    1
    
        channels:
        - name: stable-4.17
          type: ocp
      operators:
      - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.17
        packages:
        - name: serverless-operator
          channels:
          - name: stable
      additionalImages: 
    2
    
      - name: registry.redhat.io/ubi8/ubi:latest
      helm: {} 
    3

    1
    The platform field and related fields are not supported by MicroShift and must be deleted.
    2
    Specify any additional images to include in the image set. If you do not need to specify additional images, delete this field.
    3
    Helm is not supported by MicroShift and must be deleted.
  2. Edit the values of your image set configuration file to meet the requirements of both MicroShift and the Operator you want to mirror, like the following example:

    Example edited MicroShift image set configuration file

    kind: ImageSetConfiguration
    apiVersion: mirror.openshift.io/v1alpha2
    storageConfig: 
    1
    
      registry:
        imageURL: <storage_backend> 
    2
    
        skipTLS: false
    mirror:
      operators:
      - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.17 
    3
    
        packages:
        - name: amq-broker-rhel8 
    4
    
          channels:
          - name: 7.11.x 
    5

    1
    Set the backend location where the image set metadata is saved. This location can be a registry or local directory. It is required to specify storageConfig values.
    2
    Set the registry URL for the storage backend, such as <example.com/mirror/oc-mirror-metadata.
    3
    Set the Operator catalog to retrieve images from.
    4
    Specify the Operator packages to include in the image set. Remove this field to retrieve all packages in the catalog.
    5
    Specify only certain channels of the Operator packages to include in the image set. You must always include the default channel for the Operator package even if you do not use the bundles in that channel. You can find the default channel by running the following command: oc mirror list operators --catalog=<catalog_name> --package=<package_name>.
  3. Save the updated file.

Next steps

  • Use the oc-mirror plugin to mirror an image set directly to a target mirror registry.
  • Configure CRI-O.
  • Apply the catalog sources to your clusters.
8.3.2.3.1. Image set configuration parameters

The oc-mirror plugin requires an image set configuration file that defines what images to mirror. The following table lists the available parameters for the ImageSetConfiguration resource.

Expand
表8.2 ImageSetConfiguration parameters
ParameterDescriptionValues

apiVersion

The API version for the ImageSetConfiguration content.

String. For example: mirror.openshift.io/v1alpha2.

mirror

The configuration of the image set.

Object

mirror.additionalImages

The additional images configuration of the image set.

Array of objects. For example:

additionalImages:
  - name: registry.redhat.io/ubi8/ubi:latest

mirror.additionalImages.name

The tag or digest of the image to mirror.

String. For example: registry.redhat.io/ubi8/ubi:latest

mirror.blockedImages

The full tag, digest, or pattern of images to block from mirroring.

Array of strings. For example: docker.io/library/alpine

mirror.operators

The Operators configuration of the image set.

Array of objects. For example:

operators:
  - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.17
    packages:
      - name: elasticsearch-operator
        minVersion: '2.4.0'

mirror.operators.catalog

The Operator catalog to include in the image set.

String. For example: registry.redhat.io/redhat/redhat-operator-index:v4.17.

mirror.operators.full

When true, downloads the full catalog, Operator package, or Operator channel.

Boolean. The default value is false.

mirror.operators.packages

The Operator packages configuration.

Array of objects. For example:

operators:
  - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.17
    packages:
      - name: elasticsearch-operator
        minVersion: '5.2.3-31'

mirror.operators.packages.name

The Operator package name to include in the image set

String. For example: elasticsearch-operator.

mirror.operators.packages.channels

The Operator package channel configuration.

Object

mirror.operators.packages.channels.name

The Operator channel name, unique within a package, to include in the image set.

String. For example: fast or stable-v4.17.

mirror.operators.packages.channels.maxVersion

The highest version of the Operator mirror across all channels in which it exists. See the following note for further information.

String. For example: 5.2.3-31

mirror.operators.packages.channels.minBundle

The name of the minimum bundle to include, plus all bundles in the update graph to the channel head. Set this field only if the named bundle has no semantic version metadata.

String. For example: bundleName

mirror.operators.packages.channels.minVersion

The lowest version of the Operator to mirror across all channels in which it exists. See the following note for further information.

String. For example: 5.2.3-31

mirror.operators.packages.maxVersion

The highest version of the Operator to mirror across all channels in which it exists. See the following note for further information.

String. For example: 5.2.3-31.

mirror.operators.packages.minVersion

The lowest version of the Operator to mirror across all channels in which it exists. See the following note for further information.

String. For example: 5.2.3-31.

mirror.operators.skipDependencies

If true, dependencies of bundles are not included.

Boolean. The default value is false.

mirror.operators.targetCatalog

An alternative name and optional namespace hierarchy to mirror the referenced catalog as.

String. For example: my-namespace/my-operator-catalog

mirror.operators.targetName

An alternative name to mirror the referenced catalog as.

The targetName parameter is deprecated. Use the targetCatalog parameter instead.

String. For example: my-operator-catalog

mirror.operators.targetTag

An alternative tag to append to the targetName or targetCatalog.

String. For example: v1

storageConfig

The back-end configuration of the image set.

Object

storageConfig.local

The local back-end configuration of the image set.

Object

storageConfig.local.path

The path of the directory to contain the image set metadata.

String. For example: ./path/to/dir/.

storageConfig.registry

The registry back-end configuration of the image set.

Object

storageConfig.registry.imageURL

The back-end registry URI. Can optionally include a namespace reference in the URI.

String. For example: quay.io/myuser/imageset:metadata.

storageConfig.registry.skipTLS

Optionally skip TLS verification of the referenced back-end registry.

Boolean. The default value is false.

注記

Using the minVersion and maxVersion properties to filter for a specific Operator version range can result in a multiple channel heads error. The error message states that there are multiple channel heads. This is because when the filter is applied, the update graph of the Operator is truncated.

Operator Lifecycle Manager requires that every Operator channel contains versions that form an update graph with exactly one end point, that is, the latest version of the Operator. When the filter range is applied, that graph can turn into two or more separate graphs or a graph that has more than one end point.

To avoid this error, do not filter out the latest version of an Operator. If you still run into the error, depending on the Operator, either the maxVersion property must be increased or the minVersion property must be decreased. Because every Operator graph can be different, you might need to adjust these values until the error resolves.

8.3.2.4. Mirroring from mirror to mirror

You can use the oc-mirror plugin to mirror an image set directly to a target mirror registry that is accessible during image set creation.

You are required to specify a storage backend in the image set configuration file. This storage backend can be a local directory or a Docker v2 registry. The oc-mirror plugin stores metadata in this storage backend during image set creation.

重要

Do not delete or modify the metadata that is generated by the oc-mirror plugin. You must use the same storage backend every time you run the oc-mirror plugin for the same mirror registry.

Prerequisites

  • You have access to the internet to get the necessary container images.
  • You have installed the OpenShift CLI (oc).
  • You have installed the oc-mirror CLI plugin.
  • You have created the image set configuration file.

Procedure

  • Run the oc mirror command to mirror the images from the specified image set configuration to a specified registry:

    $ oc mirror --config=./<imageset-config.yaml> \
    1
    
      docker://registry.example:5000             
    2
    1
    Specify the image set configuration file that you created. For example, imageset-config.yaml.
    2
    Specify the registry to mirror the image set file to. The registry must start with docker://. If you specify a top-level namespace for the mirror registry, you must also use this same namespace on subsequent executions.

Example output

Rendering catalog image "registry.example.com/redhat/redhat-operator-index:v{ocp-version}" with file-based catalog

Verification

  1. Navigate into the oc-mirror-workspace/ directory that was generated.
  2. Navigate into the results directory, for example, results-1639608409/.
  3. Verify that YAML files are present for the ImageContentSourcePolicy and CatalogSource resources.
重要

The ImageContentSourcePolicy YAML file is used as reference content for manual configuration of CRI-O in MicroShift. You cannot apply the resource directly into a MicroShift cluster.

Next steps

  • Convert the ImageContentSourcePolicy YAML content for use in manually configuring CRI-O.
  • If required, mirror the images from mirror to disk for disconnected or offline use.
  • Configure your cluster to use the resources generated by oc-mirror.

8.3.2.5. Configuring CRI-O for using a registry mirror for Operators

You must transform the imageContentSourcePolicy.yaml file created with the oc-mirror plugin into a format that is compatible with the CRI-O container runtime configuration used by MicroShift.

Prerequisites

  • The OpenShift CLI (oc) is installed.
  • Operator Lifecycle Manager (OLM) is installed.
  • The oc-mirror OpenShift CLI (oc) plugin is installed.
  • The yq binary is installed.
  • ImageContentSourcePolicy and CatalogSource YAML files are available in the oc-mirror-workspace/results-* directory.

Procedure

  1. Confirm the contents of the imageContentSourcePolicy.yaml file by running the following command:

    $ cat oc-mirror-workspace/<results-directory>/imageContentSourcePolicy.yaml 
    1
    1
    Specify the results directory name, such as <results-1707148826>.

    Example output

    apiVersion: operator.openshift.io/v1alpha1
    kind: ImageContentSourcePolicy
    metadata:
      labels:
        operators.openshift.org/catalog: "true"
      name: operator-0
    spec:
      repositoryDigestMirrors:
      - mirrors:
        - registry.<example.com>/amq7
        source: registry.redhat.io/amq7

  2. Transform the imageContentSourcePolicy.yaml into a format ready for CRI-O configuration by running the following command:

    yq '.spec.repositoryDigestMirrors[] as $item ireduce([]; . + [{"mirror": $item.mirrors[], "source": ($item | .source)}]) | .[] |
      "[[registry]]
          prefix = \"" + .source + "\"
          location = \"" + .mirror + "\"
          mirror-by-digest-only = true
          insecure = true
          "' ./icsp.yaml

    Example output

    [[registry]]
          prefix = "registry.redhat.io/amq7"
          location = "registry.example.com/amq7"
          mirror-by-digest-only = true
          insecure = true

  3. Add the output to the CRI-O configuration file in the /etc/containers/registries.conf.d/ directory:

    Example crio-config.yaml mirror configuration file

    [[registry]]
          prefix = "registry.redhat.io/amq7"
          location = "registry.example.com/amq7"
          mirror-by-digest-only = true
          insecure = true
    
    [[registry]]
        prefix = ""
        location = "quay.io"
        mirror-by-digest-only = true
    [[registry.mirror]]
        location = "<registry_host>:<port>" 
    1
    
        insecure = false

    1
    Specify the host name and port of your mirror registry server, for example microshift-quay:8443.
  4. Apply the CRI-O configuration changes by restarting MicroShift with the following command:

    $ sudo systemctl restart crio

8.3.2.6. Installing a custom catalog created with the oc-mirror plugin

After you mirror your image set to the mirror registry, you must apply the generated CatalogSource custom resource (CR) into the cluster. The CatalogSource CR is used by Operator Lifecycle Manager (OLM) to retrieve information about the available Operators in the mirror registry. You must then create and apply a subscription CR to subscribe to your custom catalog.

Prerequisites

  • You mirrored the image set to your registry mirror.
  • You added image reference information to the CRI-O container runtime configuration.

Procedure

  1. Apply the catalog source configuration file from the results directory to create the catalog source object by running the following command:

    $ oc apply -f ./oc-mirror-workspace/results-1708508014/catalogSource-cs-redhat-operator-index.yaml

    Example catalog source configuration file

    apiVersion: operators.coreos.com/v1alpha1
    kind: CatalogSource
    metadata:
      name: redhat-catalog
      namespace: openshift-marketplace 
    1
    
    spec:
      sourceType: grpc
      image: registry.example.com/redhat/redhat-operator-index:v4.17
      updateStrategy:
        registryPoll:
          interval: 60m

    1
    Specifies the global namespace. Setting the metadata.namespace to openshift-marketplace enables the catalog to reference catalogs in all namespaces. Subscriptions in any namespace can reference catalogs created in the openshift-marketplace namespace.

    Example output

    catalogsource.operators.coreos.com/cs-redhat-operator-index created

  2. Verify that the CatalogSource resources were successfully installed by running the following command:

    $ oc get catalogsource --all-namespaces
  3. Verify that the catalog source is running by using the following command:

    $ oc get pods -n openshift-marketplace

    Example output

    NAME                             READY   STATUS    RESTARTS   AGE
    cs-redhat-operator-index-4227b   2/2     Running   0          2m5s

  4. Create a Subscription CR, similar to the following example:

    Example Subscription CR

    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: amq-broker
      namespace: openshift-operators
    spec:
      channel: 7.11.x
      name: amq-broker-rhel8
      source: cs-redhat-operator-index
      sourceNamespace: openshift-marketplace

  5. Apply the Subscription CR configuration by running the following command:

    $ oc apply -f ./<my-subscription-cr.yaml> 
    1
    1
    Specify the name of your subscription, such as my-subscription-cr.yaml.

    Example output

    subscription.operators.coreos.com/amq-broker created

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る