How to mirror only a specific version of an operator using oc-mirror plugin

Solution Verified - Updated

Environment

  • Red Hat OpenShift Container Platform 4.10 or later.
  • oc-mirror

Issue

  • How to mirror only a specific version of an operator from a channel.
  • How to mirror only few operator versions from a channel.
  • How to mirror only latest version of an operator from default channel.
  • How to mirror latest version of an operator from all the available channel.
  • How to mirror an operator till a particular version from a channel.
  • How to mirror an operator from a specific version to latest version from a channel.

Resolution

  • How to mirror only a specific version of an operator from a channel.
apiVersion: mirror.openshift.io/v1alpha2
kind: ImageSetConfiguration
storageConfig:
  registry:
    imageURL: <registry>:8443/mirror/oc-mirror-metadata                 
    skipTLS: false
mirror:
  operators:
    - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.12
      packages:
        - name: quay-operator
          channels:
          - name: stable-3.9
            minVersion: 3.9.0
            maxVersion: 3.9.0
  • How to mirror only few operator versions from a channel ( below ImageSetConfiguration will help to mirror all the intermediate version including minVersion and maxVersion ).
apiVersion: mirror.openshift.io/v1alpha2
kind: ImageSetConfiguration
storageConfig:
  registry:
    imageURL: <registry>:8443/mirror/oc-mirror-metadata                 
    skipTLS: false
mirror:
  operators:
    - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.12
      packages:
        - name: quay-operator
          channels:
          - name: stable-3.9
            minVersion: 3.9.1
            maxVersion: 3.9.4
  • How to mirror only latest version of an operator from default channel ( Find out the default channel using any of the method described in the "Diagnostic Steps" and mention only default channel name ).
apiVersion: mirror.openshift.io/v1alpha2
kind: ImageSetConfiguration
storageConfig:
  registry:
    imageURL: <registry>:8443/mirror/oc-mirror-metadata                 
    skipTLS: false
mirror:
  operators:
    - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.12
      packages:
        - name: quay-operator
          channels:
          - name: stable-x
  • How to mirror latest version of an operator from all the available channel ( if no channel specified latest version from all the channels will be mirrored ).
apiVersion: mirror.openshift.io/v1alpha2
kind: ImageSetConfiguration
storageConfig:
  registry:
    imageURL: <registry>:8443/mirror/oc-mirror-metadata                 
    skipTLS: false
mirror:
  operators:
    - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.12
      packages:
        - name: quay-operator
  • How to mirror an operator till a particular version from a channel ( if maxVersion set alone, then all the available versions till the maxVersion will be mirrored).
apiVersion: mirror.openshift.io/v1alpha2
kind: ImageSetConfiguration
storageConfig:
  registry:
    imageURL: <registry>:8443/mirror/oc-mirror-metadata                 
    skipTLS: false
mirror:
  operators:
    - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.12
      packages:
        - name: quay-operator
          channels:
          - name: stable-3.9
            maxVersion: 3.9.4
  • How to mirror an operator from a specific version to latest version from a channel ( if minVersion set alone, then all the available versions from the minVersion to latest version will be mirrored).
apiVersion: mirror.openshift.io/v1alpha2
kind: ImageSetConfiguration
storageConfig:
  registry:
    imageURL: <registry>:8443/mirror/oc-mirror-metadata                 
    skipTLS: false
mirror:
  operators:
    - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.12
      packages:
        - name: quay-operator
          channels:
          - name: stable-3.9
            minVersion: 3.9.1

Root Cause

The tool oc-mirror provides a feature to fetch the images via the ImageSetConfiguration that provides a list of operators to be mirrored from the index container image (called catalog above).
The user can use minVersion and maxVersion to prune/customize the packages manifests that come from the catalog (container image) available for the mirroring process.

Diagnostic Steps

# oc-mirror list operators --catalog=registry.redhat.io/redhat<redhat/certified/community operator index image>:v<ocp-version> --package <operator-name> --> to see all the available channels

# oc-mirror list operators --catalog=registry.redhat.io/redhat<redhat/certified/community operator index image>:v<ocp-version> --package <operator-name> --channel <channel-name> --> to see all the available versions in a particular channel
  • See examples below:
# oc-mirror list operators --catalog=registry.redhat.io/redhat/redhat-operator-index:v4.12 --package quay-operator
# oc-mirror list operators --catalog=registry.redhat.io/redhat/redhat-operator-index:v4.12 --package quay-operator --channel stable-3.9
Tags

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.