Deploying onto OpenShift

This section is to help you verify that the operator deploys successfully from the metadata bundle onto OpenShift using the Operator Lifecycle Manager (OLM).

Before getting started

Install the operator package manager (OPM) tool

Creating an index image

You can create an index image using the opm CLI.

  1. Start a new index:

    $ opm index add \
        --bundles<namespace>/wordpress-operator:v0.0.1 \
  2. Push the index image to a registry:

    $ podman push<namespace>/wordpress-operator-index:latest

Be sure to make your repositories for the bundle image and the index image public. You can can change this in the settings in

Create the CatalogSource

  1. In your OpenShift environment create a catalog source in the openshift-marketplace namespace.

kind: CatalogSource
  name: my-test-operators
  namespace: openshift-marketplace
  sourceType: grpc
  displayName: Test Operators
  publisher: Red Hat Partner
      interval: 5m
$ oc create -f test-operator-catalogsource.yaml 

2. You can verify the catalogsource has been created by running the following command:

$ oc -n openshift-marketplace get catalogsource

You should see the following output:

NAME                  DISPLAY               TYPE   PUBLISHER   AGE
certified-operators   Certified Operators   grpc   Red Hat     12d
community-operators   Community Operators   grpc   Red Hat     12d
my-test-operators     Test Operators        grpc   Red Hat     30s
redhat-marketplace    Red Hat Marketplace   grpc   Red Hat     12d
redhat-operators      Red Hat Operators     grpc   Red Hat     12d

3. Once you have confirmed the catalogsource exists, run the following command to verify it's associated pod is successfully running. This verifies that the index image has been successfully pulled down from the repository.

$ oc -n openshift-marketplace get pods

You should see the following output:

NAME                                    READY   STATUS    RESTARTS   AGE
certified-operators-59b6bc7fbc-rzzwq    1/1     Running   0          12d
community-operators-5f89b4787d-ljvfb    1/1     Running   0          12d
marketplace-operator-5c84994668-927b6   1/1     Running   0          12d
my-test-operators-##########-#####      1/1     Running   0          12d
redhat-marketplace-86cc645bb6-8crdl     1/1     Running   0          12d
redhat-operators-5877478c4f-4ffs2       1/1     Running   0          12d

4. Verify that the operator package has been successfully added:

$ oc get packagemanifests | grep “Test Operators”

Create OperatorGroup

  1. Create a namespace for your project

 $ oc new-project test-operator

2. Create the OperatorGroup

kind: OperatorGroup
  name: my-group
  namespace: test-operator
    - test-operator
$ oc create -f test-operatorgroup.yaml

3. Verify you have a working operatorgroup within the namespace you created:

$ oc get og

You should see the following output:

NAMESPACE                              NAME                           AGE
test-operator                          my-group                       30s 

Create a Subscription

kind: Subscription
  name: test-subscription
  channel: alpha
  installPlanApproval: Automatic
  name: wordpress-operator
  source: my-test-operators
  sourceNamespace: openshift-marketplace
$ oc create -f test-subscription.yaml

Verify the subscription is created within your namespace:

$ oc get sub -n test-operator

You should see the following output:

NAMESPACE             NAME                              PACKAGE                           SOURCE                CHANNEL
test-operator         test-subscription                 wordpress-operator                test-operators        stable

The creation of the subscription should trigger the creation of the InstallPlan and CSV.

$ oc get installplan -n test-operator
$ oc get csv -n test-operator

You should see something similar to this output:

NAMESPACE                                          NAME                             DISPLAY                                 VERSION   REPLACES   PHASE
test-operator                                      wordpress-operator.v0.0.1        Wordpress Operator                      0.0.1                Succeeded

Verify your operator is running in the namespace:

$ oc get pods -n test-operator

Updating an existing index image

You can update an existing index image with a new operator bundle version using the opm CLI.

  1. Update the existing index:

    $ opm index add \
        --bundles<namespace>/wordpress-operator:v0.0.2 \
        --from-index<namespace>/wordpress-operator-index:latest \
  2. Push the updated index image:

    $ podman push<namespace>/wordpress-operator-index:latest
  3. After OLM polls the index image at its specified interval, we should eventually see a new installplan for our new operator bundle version

    $ oc get installplan -n test-operator

Run the Scorecard test

The Operator Scorecard is a testing utility included in the operator-sdk binary that guides users towards operator best practices by checking the correctness of their operators and CSVs. With your operator deployed via OLM, you can run the operator-sdk scorecard utility to create a CR which will trigger the operator and monitor what occurs. In order to certify you must pass the first two Basic Tests: Spec Block Exists, and Status Block Exists. Passing the third basic test (Writing into CRs has an effect) requires adding the scorecard-proxy container to the operator deployment, which is not desired in a production operator and is therefore not required for certification.

In order to run scorecard locally against your operator deployed via OLM please refer to this section of the upstream documentation

Last updated