This is a cache of https://docs.openshift.com/container-platform/4.1/applications/operators/olm-adding-operators-to-cluster.html. It is a snapshot of the page at 2024-11-23T02:48:28.225+0000.
Adding Operators to a cluster - Operators | Applications | OpenShift Container Platform 4.1
×

This guide walks cluster administrators through installing Operators to an OpenShift Container Platform cluster.

Installing Operators from the OperatorHub

As a cluster administrator, you can install an Operator from the OperatorHub using the OpenShift Container Platform web console or the CLI. You can then subscribe the Operator to one or more namespaces to make it available for developers on your cluster.

During installation, you must determine the following initial settings for the Operator:

Installation Mode

Choose All namespaces on the cluster (default) to have the Operator installed on all namespaces or choose individual namespaces, if available, to only install the Operator on selected namespaces. This example chooses All namespaces…​ to make the Operator available to all users and projects.

Update Channel

If an Operator is available through multiple channels, you can choose which channel you want to subscribe to. For example, to deploy from the stable channel, if available, select it from the list.

Approval Strategy

You can choose Automatic or Manual updates. If you choose Automatic updates for an installed Operator, when a new version of that Operator is available, the Operator Lifecycle Manager (OLM) automatically upgrades the running instance of your Operator without human intervention. If you select Manual updates, when a newer version of an Operator is available, the OLM creates an update request. As a cluster administrator, you must then manually approve that update request to have the Operator updated to the new version.

Installing from the OperatorHub using the web console

This procedure uses the Couchbase Operator as an example to install and subscribe to an Operator from the OperatorHub using the OpenShift Container Platform web console.

Prerequisites
  • Access to an OpenShift Container Platform cluster using an account with cluster-admin permissions.

Procedure
  1. Navigate in the web console to the Catalog → OperatorHub page.

  2. Scroll or type a keyword into the Filter by keyword box (in this case, Couchbase) to find the Operator you want.

    olm operatorhub
    Figure 1. Filter Operators by keyword
  3. Select the Operator. For a Community Operator, you are warned that Red Hat does not certify those Operators. You must acknowledge that warning before continuing. Information about the Operator is displayed.

  4. Read the information about the Operator and click Install.

  5. On the Create Operator Subscription page:

    1. Select one of the following:

      • All namespaces on the cluster (default) installs the Operator in the default openshift-operators namespace to watch and be made available to all namespaces in the cluster. This option is not always available.

      • A specific namespace on the cluster allows you to choose a specific, single namespace in which to install the Operator. The Operator will only watch and be made available for use in this single namespace.

    2. Select an Update Channel (if more than one is available).

    3. Select Automatic or Manual approval strategy, as described earlier.

  6. Click Subscribe to make the Operator available to the selected namespaces on this OpenShift Container Platform cluster.

  7. From the Catalog → Operator Management page, you can monitor an Operator Subscription’s installation and upgrade progress.

    1. If you selected a Manual approval strategy, the Subscription’s upgrade status will remain Upgrading until you review and approve its Install Plan.

      olm manualapproval
      Figure 2. Manually approving from the Install Plan page

      After approving on the Install Plan page, the Subscription upgrade status moves to Up to date.

    2. If you selected an Automatic approval strategy, the upgrade status should resolve to Up to date without intervention.

      olm uptodate
      Figure 3. Subscription upgrade status Up to date
  8. After the Subscription’s upgrade status is Up to date, select Catalog → Installed Operators to verify that the Couchbase ClusterServiceVersion (CSV) eventually shows up and its Status ultimately resolves to InstallSucceeded in the relevant namespace.

    For the All namespaces…​ Installation Mode, the status resolves to InstallSucceeded in the openshift-operators namespace, but the status is Copied if you check in other namespaces.

    If it does not:

    1. Switch to the Catalog → Operator Management page and inspect the Operator Subscriptions and Install Plans tabs for any failure or errors under Status.

    2. Check the logs in any Pods in the openshift-operators project (or other relevant namespace if A specific namespace…​ Installation Mode was selected) on the Workloads → Pods page that are reporting issues to troubleshoot further.

Installing from the OperatorHub using the CLI

Instead of using the OpenShift Container Platform web console, you can install an Operator from the OperatorHub using the CLI. Use the oc command to create or update a CatalogSourceConfig object, then add a Subscription object.

The web console version of this procedure handles the creation of the CatalogSourceConfig and Subscription objects behind the scenes for you, appearing as if it was one step.

Prerequisites
  • Access to an OpenShift Container Platform cluster using an account with cluster-admin permissions.

  • Install the oc command to your local system.

Procedure
  1. View the list of Operators available to the cluster from the OperatorHub:

    $ oc get packagemanifests -n openshift-marketplace
    NAME                     AGE
    amq-streams              14h
    packageserver            15h
    couchbase-enterprise     14h
    mongodb-enterprise       14h
    etcd                     14h
    myoperator               14h
    ...
  2. To identify the Operators to enable on the cluster, create a CatalogSourceConfig object YAML file (for example, csc.cr.yaml). Include one or more packages listed in the previous step (such as couchbase-enterprise or etcd). For example:

    Example CatalogSourceConfig
    apiVersion: operators.coreos.com/v1
    kind: CatalogSourceConfig
    metadata:
      name: example
      namespace: openshift-marketplace
    spec:
      targetNamespace: openshift-operators (1)
      packages: myoperator (2)
    1 Set the targetNamespace to identify the namespace where you want the Operator to be available. The openshift-operators namespace is watched by the Operator Lifecycle Manager (OLM).
    2 Set packages to a comma-separated list of Operators to which you want to subscribe.

    The Operator generates a CatalogSource from your CatalogSourceConfig in the namespace specified in targetNamespace.

  3. Create the CatalogSourceConfig to enable the specified Operators in the selected namespace:

    $ oc apply -f csc.cr.yaml
  4. Create a Subscription object YAML file (for example, myoperator-sub.yaml) to subscribe a namespace to an Operator. Note that the namespace you pick must have an OperatorGroup that matches the installMode (either AllNamespaces or SingleNamespace modes):

    Example Subscription
    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: myoperator
      namespace: openshift-operators
    spec:
      channel: alpha
      name: myoperator (1)
      source: example (2)
      sourceNamespace: openshift-operators
    1 Name of the Operator to subscribe to.
    2 Name of the CatalogSource that was created.
  5. Create the Subscription object:

    $ oc apply -f myoperator-sub.yaml

    At this point, the OLM is now aware of the selected Operator. A ClusterServiceVersion (CSV) for the Operator should appear in the target namespace, and APIs provided by the Operator should be available for creation.

  6. Later, if you want to install more Operators:

    1. Update your CatalogSourceConfig file (in this example, csc.cr.yaml) with more packages. For example:

      Example updated CatalogSourceConfig
      apiVersion: operators.coreos.com/v1
      kind: CatalogSourceConfig
      metadata:
        name: example
        namespace: openshift-marketplace
      spec:
        targetNamespace: global
        packages: myoperator,another-operator (1)
      1 Add new packages to existing package list.
    2. Update the CatalogSourceConfig object:

      $ oc apply -f csc.cr.yaml
    3. Create additional Subscription objects for the new Operators.

Additional resources
  • To install custom Operators to a cluster using the OperatorHub, you must first upload your Operator artifacts to Quay.io, then add your own OperatorSource to your cluster. Optionally, you can add Secrets to your Operator to provide authentication. After, you can manage the Operator in your cluster as you would any other Operator. For these steps, see Testing Operators.