Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

How to get Red Hat OpenShift operators' information without oc-mirror plug-in

July 23, 2024
Eric Beaudoin
Related topics:
Automation and managementContainersDisconnected environmentsKubernetesOperators
Related products:
Red Hat OpenShiftRed Hat OpenShift Container Platform

    Deploying a Red Hat OpenShift operator in an online environment is a breeze! OpenShift will simply pull the required images from public registries, and voila, we're good to use it without any hassle.

    However, the game changes when we're working in a disconnected environment. For most customers, keeping their servers off the internet is a top priority due to security concerns. Suddenly, deploying an OpenShift operator becomes more intricate and we can't rely on public registries anymore. Instead, we need to gather all the necessary container images and make sure they're available within our disconnected environment. Only then can we successfully deploy an operator on OpenShift. 

    Using oc-mirror in a typical environment

    When deploying the OpenShift operators in a disconnected environment, one of the first steps is to mirror images from Red Hat’s public registries to a private registry. The oc-mirror plug-in is commonly used for this and requires an ImageSetConfiguration file detailing the catalogs’ and operators' names, channels, and versions used in the disconnected environment.  

    One of the challenges with using oc-mirror is the time-consuming nature of collecting information for multiple operators, especially considering that the command needs to be run 2-3 times per operator.  It makes the process cumbersome for system administrators, and repetitive tasks like this can be tedious and prone to errors. Although this process can be improved with automation, it is not always feasible to take the required time when we have deadlines to meet.

    In this article, we'll explore an alternative approach to gathering this information efficiently without relying on oc-mirror. By leveraging some simple shell scripts, we will demonstrate how to automate this task effectively, enabling system administrators to save time and improve efficiency in their deployment workflows. Let's dive in and explore how to simplify collecting the OpenShift operator information through scripting.

    What I mean by time-consuming using oc-mirror

    Before we jump into the benefits of scripting for speeding up tasks, let's first explore why using oc-mirror plug-in to find details about the OpenShift operator can be quite time-consuming.

    Consider the task of gathering information about the advanced-cluster-management operator. Since we will only ever use one version at a time, mirroring all versions of the channel is unnecessary. Therefore, we need to pinpoint the release version for a specific channel.

    1. Confirm the operator is part of the Red Hat catalog’s operator:

      $ time oc-mirror list operators --catalog registry.redhat.io/redhat/redhat-operator-index:v4.15 |grep advanced-cluster-management 

      Output: 

      advanced-cluster-management                   Advanced Cluster Management for Kubernetes               release-2.10
      real 1m7.263s
    2. List all available channels in a package:

      $ time oc-mirror list operators --catalog registry.redhat.io/redhat/redhat-operator-index:v4.15 --package advanced-cluster-management

      Output:

      NAME                         DISPLAY NAME                                DEFAULT CHANNEL
      advanced-cluster-management  Advanced Cluster Management for Kubernetes  release-2.10
      PACKAGE                      CHANNEL       HEAD
      advanced-cluster-management  release-2.10  advanced-cluster-management.v2.10.3
      advanced-cluster-management  release-2.9   advanced-cluster-management.v2.9.4
      real 1m5.233s
    3. List all available versions in a channel:

      $ time oc-mirror list operators --catalog registry.redhat.io/redhat/redhat-operator-index:v4.15 --package advanced-cluster-management --channel release-2.10

      Output:

      VERSIONS
      2.10.0
      2.10.1
      2.10.2
      2.10.3
      real 1m2.604s

    I included the time command to demonstrate the duration of running the oc-mirror plug-in command. Each of the three commands takes over three minutes to produce output. When multiplied by the number of operators requiring mirroring, there is clearly a need to develop a faster method for gathering operator information to configure the ImageSetConfiguration file required by the oc-mirror plugin.

    Introducing a faster method

    Since OpenShift v4.11, file-based catalogs have emerged as the latest iteration of the catalog format in Operator Lifecycle Manager (OLM). This format, characterized by plain file-based JSON files, represents a major evolution towards a declarative configuration compared to the earlier SQLite database format, making the process of extracting information from image catalogs remarkably more straight-forward

    To retrieve an operator’s information, we simply need to copy it from the image catalog operators’ folder to a local drive. Within that directory lies one or multiple files of all the operators delivered with that specific catalog. It is facilitating the access to the operators’ data. Below is an example illustrating the process of copying the operator’s directory from the Red Hat operator catalog’s image.

    1. Make sure you have the latest version of the Red Hat catalog’s operator:

      $ podman pull registry.redhat.io/redhat/redhat-operator-index:v4.15
    2. Find the directory that contains all the operators' definition:

      $ podman inspect --format '{{index .Config.Labels "operators.operatorframework.io.index.configs.v1"}}' registry.redhat.io/redhat/redhat-operator-index:v4.15

      Output:

      /configs
    3. Run the catalog container using Podman:

      $ podman run -d --name redhat-catalog registry.redhat.io/redhat/redhat-operator-index:v4.15
    4. Copy the configs directory to a local disk:

      $ podman cp redhat-catalog:/configs .
      
      $ cd configs
      
      $ ls -lt

      Output:

      drwxr-xr-x 2 admin admin  26 Jun  3 15:22 3scale-operator
      drwxr-xr-x 2 admin admin 179 Jun 13 13:05 advanced-cluster-management
      drwxr-xr-x 2 admin admin  26 Jun  3 15:22 amq7-interconnect-operator
      drwxr-xr-x 2 admin admin  26 Jun  3 15:22 amq-broker-rhel8
      drwxr-xr-x 2 admin admin  26 Jun  3 15:22 amq-online
      drwxr-xr-x 2 admin admin  26 Jun  3 15:22 amq-streams
      drwxr-xr-x 2 admin admin  26 Jun  3 15:22 ansible-automation-platform-operator
      drwxr-xr-x 2 admin admin  26 Jun  3 15:22 ansible-cloud-addons-operator
      drwxr-xr-x 2 admin admin  26 Jun  3 15:22 apicast-operator
      drwxr-xr-x 2 admin admin  26 Jun  3 15:22 authorino-operator
      drwxr-xr-x 2 admin admin  26 Jun  3 15:22 aws-efs-csi-driver-operator
      …
      …
      …
    5. Stop the container since we don’t need it anymore:

      $ podman stop redhat-catalog
    6. Remove the container:

      $ podman rm redhat-catalog

    Collecting the operator’s details using the operator's catalog.json files

    Once the operator’s details are collected, we will find one or multiple YAML file(s) in the directory. The file(s) serve as a comprehensive repository of all the essential details about the operator. 

    In this example, the directory has one sub-directory for each operator. To extract specific information from the catalog.json file, such as advanced-cluster-management, we can leverage tools like the jq command to filter the data efficiently since the file is in JSON format. This streamlined approach simplifies the process of extracting OpenShift operator information, enhancing efficiency and enabling seamless integration into deployment workflows.

    We can extract information from the config.json file using jq command

    1. Get the operator's name:

      $ jq -cs . advanced-cluster-management/catalog.json |jq .[0].name

      Output:

      "advanced-cluster-management"
      
    2. Get all the operator release version(s) for the default channel:
      1. Get the operator default channel:

        $ time OPDEFCHAN=$(jq -cs . advanced-cluster-management/catalog.json |jq .[0].defaultChannel)

        Output:

        real 0m0.061s

        Show the content of the OPDEFCHAN variable:

        $ echo $OPDEFCHAN 

        Output:

        "release-2.10"
      2. Get the operator releases:

        $ time OPRELEASE=$(jq -cs . advanced-cluster-management/catalog.json |jq ".[] |select(.name==$OPDEFCHAN)"|jq .entries[].name)

        Output:

        real 0m0.063s

        Show the content of the OPRELEASE variable:

        $ echo $OPRELEASE

        Output:

        "advanced-cluster-management.v2.10.0" "advanced-cluster-management.v2.10.1" "advanced-cluster-management.v2.10.2" "advanced-cluster-management.v2.10.3"
    3. Get the names of the operator releases:

      $ VERSION=""
      
      $ time for release in ${OPRELEASE[@]}; do   export release=$(echo $release|tr -d "\"");   VERSION="$VERSION $(jq -cs . advanced-cluster-management/catalog.json |jq -r --arg n "$release" '.[]|select(.name == $n)'|jq '.properties[] |select(.type=="olm.package")'|jq .value.version)";done

      Output:

      real 0m0.276s

      Show the content of the VERSION variable:

      $ echo $VERSION 

      Output:

      "2.10.0" "2.10.1" "2.10.2" "2.10.3" "2.10.0" "2.10.1" "2.10.2" "2.10.3"
      
    4. Get the last value from the $VERSION array:

      $ echo $(echo $VERSION|awk '{print $NF}')

      Output:

      "2.10.3"

    Conclusion

    In conclusion, we've seen how even with minimal scripting knowledge, we can develop a script to streamline the process of gathering information on desired operators within OpenShift. By looping through these operators, we collect their respective channels and release data. It is worth noting that all default operator catalogs provided by Red Hat adhere to the same file-based format, which simplifies the scripting process.

    The benefits of scripting and automating our routine tasks are obvious. By scripting the collection of OpenShift operators, we not only save time but also enhance the efficiency of adding operators to our ImageSetConfiguration configuration file. This streamlined approach not only simplifies our workflows but also contributes to greater agility and scalability in managing our OpenShift environments.

    References

    • OpenShift documentation: https://docs.openshift.com

    • oc-mirror: https://github.com/openshift/oc-mirror/tree/main

    • jq: https://jqlang.github.io/jq/

    Last updated: January 15, 2025

    Related Posts

    • How to debug OpenShift operators on a live cluster using dlv

    • Install Red Hat OpenShift Operators on your laptop using Red Hat CodeReady Containers and Red Hat Marketplace

    • Red Hat build of Keycloak: New enhancements to the OpenShift operator experience

    Recent Posts

    • MCP servers vs. skills: Choosing the right context for your AI

    • How to route external and local LLMs with Models-as-a-Service

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    What’s up next?

    Read Operating OpenShift, a practical guide to running and operating OpenShift clusters more efficiently using a site reliability engineering (SRE) approach. Learn best practices and tools that can help reduce the effort of deploying a Kubernetes platform.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.