8.2. Using Operator Lifecycle Manager with MicroShift


The Operator Lifecycle Manager (OLM) package manager is used in MicroShift for installing and running optional add-on Operators.

8.2.1. Considerations for using OLM with MicroShift

  • Cluster Operators as applied in OpenShift Container Platform are not used in MicroShift.
  • You must create your own catalogs for the add-on Operators you want to use with your applications. Catalogs are not provided by default.

    • Each catalog must have an accessible CatalogSource added to a cluster, so that the OLM catalog Operator can use the catalog for content.
  • You must use the CLI to conduct OLM activities with MicroShift. The console and OperatorHub GUIs are not available.

重要

Before using an Operator, verify with the provider that the Operator is supported on Red Hat build of MicroShift.

8.2.2. Determining your OLM installation type

You can install the OLM package manager for use with MicroShift 4.15 or newer versions. There are different ways to install OLM for MicroShift clusters, depending on your use case.

8.2.3. Namespace use in MicroShift

The microshift-olm RPM creates the three default namespaces: one for running OLM, and two for catalog and Operator installation. You can create additional namespaces as needed for your use case.

8.2.3.1. Default namespaces

The following table lists the default namespaces and a brief description of how each namespace works.

Expand
表8.1 Default namespaces created by OLM for MicroShift

Default Namespace

Details

openshift-operator-lifecycle-manager

The OLM package manager runs in this namespace.

openshift-marketplace

The global namespace. Empty by default. To make the catalog source to be available globally to users in all namespaces, set the openshift-marketplace namespace in the catalog-source YAML.

openshift-operators

The default namespace where Operators run in MicroShift. Operators that reference catalogs in the openshift-operators namespace must have the AllNamespaces watch scope.

8.2.3.2. Custom namespaces

If you want to use a catalog and Operator together in a single namespace, then you must create a custom namespace. After you create the namespace, you must create the catalog in that namespace. All Operators running in the custom namespace must have the same single-namespace watch scope.

8.2.4. About building Operator catalogs

To use Operator Lifecycle Manager (OLM) with MicroShift, you must build custom Operator catalogs that you can then manage with OLM. The standard catalogs that are included with OpenShift Container Platform are not included with MicroShift.

8.2.4.1. File-based Operator catalogs

You can create catalogs for your custom Operators or filter catalogs of widely available Operators. You can combine both methods to create the catalogs needed for your specific use case. To run MicroShift with your own Operators and OLM, make a catalog by using the file-based catalog structure.

重要
  • When adding a catalog source to a cluster, set the securityContextConfig value to restricted in the catalogSource.yaml file. Ensure that your catalog can run with restricted permissions.

8.2.5. How to deploy Operators using OLM

After you create and deploy your custom catalog, you must create a Subscription custom resource (CR) that can access the catalog and install the Operators you choose. Where Operators run depends on the namespace in which you create the Subscription CR.

重要

Operators in OLM have a watch scope. For example, some Operators only support watching their own namespace, while others support watching every namespace in the cluster. All Operators installed in a given namespace must have the same watch scope.

8.2.5.1. Connectivity and OLM Operator deployment

Operators can be deployed anywhere a catalog is running.

  • For clusters that are connected to the internet, mirroring images is not required. Images can be pulled over the network.
  • For restricted networks in which MicroShift has access to an internal network only, images must be mirrored to an internal registry.
  • For use cases in which MicroShift clusters are completely offline, all images must be embedded into an osbuild blueprint.

8.2.5.2. Adding OLM-based Operators to a networked cluster using the global namespace

To deploy different operators to different namespaces, use this procedure. For MicroShift clusters that have network connectivity, Operator Lifecycle Manager (OLM) can access sources hosted on remote registries. The following procedure lists the basic steps of using configuration files to install an Operator that uses the global namespace.

注記

To use an Operator installed in a different namespace, or in more than one namespace, make sure that the catalog source and the Subscription CR that references the Operator are running in the openshift-marketplace namespace.

Prerequisites

  • The OpenShift CLI (oc) is installed.
  • Operator Lifecycle Manager (OLM) is installed.
  • You have created a custom catalog in the global namespace.

Procedure

  1. Confirm that OLM is running by using the following command:

    $ oc -n openshift-operator-lifecycle-manager get pod -l app=olm-operator

    Example output

    NAME                            READY   STATUS    RESTARTS   AGE
    olm-operator-85b5c6786-n6kbc    1/1     Running   0          2m24s

  2. Confirm that the OLM catalog Operator is running by using the following command:

    $ oc -n openshift-operator-lifecycle-manager get pod -l app=catalog-operator

    Example output

    NAME                                READY   STATUS    RESTARTS   AGE
    catalog-operator-5fc7f857b6-tj8cf   1/1     Running   0          2m33s

注記

The following steps assume you are using the global namespace, openshift-marketplace. The catalog must run in the same namespace as the Operator. The Operator must support the AllNamespaces mode.

  1. Create the CatalogSource object by using the following example YAML:

    Example catalog source YAML

    apiVersion: operators.coreos.com/v1alpha1
    kind: CatalogSource
    metadata:
      name: operatorhubio-catalog
      namespace: openshift-marketplace 
    1
    
    spec:
      sourceType: grpc
      image: quay.io/operatorhubio/catalog:latest
      displayName: Community Operators 
    2
    
      publisher: OperatorHub.io
      grpcPodConfig:
        securityContextConfig: restricted 
    3
    
      updateStrategy:
        registryPoll:
          interval: 60m

    1
    The global namespace. Setting the metadata.namespace to openshift-marketplace enables the catalog to run in all namespaces. Subscriptions in any namespace can reference catalogs created in the openshift-marketplace namespace.
    2
    Community Operators are not installed by default with OLM for MicroShift. Listed here for example only.
    3
    The value of securityContextConfig must be set to restricted for MicroShift.
  2. Apply the CatalogSource configuration by running the following command:

    $ oc apply -f <my-catalog-source.yaml> 
    1
    1
    Replace <my-catalog-source.yaml> with your catalog source configuration file name. In this example, catalogsource.yaml is used.

    Example output

    catalogsource.operators.coreos.com/operatorhubio-catalog created

  3. To verify that the catalog source is applied, check for the READY state by using the following command:

    $ oc describe catalogsources.operators.coreos.com -n openshift-marketplace operatorhubio-catalog

    Example output

    Name:         operatorhubio-catalog
    Namespace:    openshift-marketplace
    Labels:       <none>
    Annotations:  <none>
    API Version:  operators.coreos.com/v1alpha1
    Kind:         CatalogSource
    Metadata:
      Creation Timestamp:  2024-01-31T09:55:31Z
      Generation:          1
      Resource Version:    1212
      UID:                 4edc1a96-83cd-4de9-ac8c-c269ca895f3e
    Spec:
      Display Name:  Community Operators
      Grpc Pod Config:
        Security Context Config:  restricted
      Image:                      quay.io/operatorhubio/catalog:latest
      Publisher:                  OperatorHub.io
      Source Type:                grpc
      Update Strategy:
        Registry Poll:
          Interval:  60m
    Status:
      Connection State:
        Address:              operatorhubio-catalog.openshift-marketplace.svc:50051
        Last Connect:         2024-01-31T09:55:57Z
        Last Observed State:  READY 
    1
    
      Registry Service:
        Created At:         2024-01-31T09:55:31Z
        Port:               50051
        Protocol:           grpc
        Service Name:       operatorhubio-catalog
        Service Namespace:  openshift-marketplace
    Events:                 <none>

    1
    The status is reported as READY.
  4. Confirm that the catalog source is running by using the following command:

    $ oc get pods -n openshift-marketplace -l olm.catalogSource=operatorhubio-catalog

    Example output

    NAME                          READY   STATUS    RESTARTS   AGE
    operatorhubio-catalog-x24nh   1/1     Running   0          59s

  5. Create a Subscription CR configuration file by using the following example YAML:

    Example Subscription custom resource YAML

    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: my-cert-manager
      namespace: openshift-operators
    spec:
      channel: stable
      name: cert-manager
      source: operatorhubio-catalog
      sourceNamespace: openshift-marketplace 
    1

    1
    The global namespace. Setting the sourceNamespace value to openshift-marketplace enables Operators to run in multiple namespaces if the catalog also runs in the openshift-marketplace namespace.
  6. Apply the Subscription CR configuration by running the following command:

    $ oc apply -f <my-subscription-cr.yaml> 
    1
    1
    Replace <my-subscription-cr.yaml> with your Subscription CR filename. In this example, sub.yaml is used.

    Example output

    subscription.operators.coreos.com/my-cert-manager created

  7. You can create a configuration file for the specific Operand you want to use and apply it now.

Verification

  1. Verify that your Operator is running by using the following command:

    $ oc get pods -n openshift-operators 
    1
    1
    The namespace from the Subscription CR is used.
    注記

    Allow a minute or two for the Operator start.

    Example output

    NAME                                       READY   STATUS    RESTARTS   AGE
    cert-manager-7df8994ddb-4vrkr              1/1     Running   0          19s
    cert-manager-cainjector-5746db8fd7-69442   1/1     Running   0          18s
    cert-manager-webhook-f858bf58b-748nt       1/1     Running   0          18s

8.2.5.3. Adding OLM-based Operators to a networked cluster in a specific namespace

Use this procedure if you want to specify a namespace for an Operator, for example, olm-microshift. In this example, the catalog is scoped and available in the global openshift-marketplace namespace. The Operator uses content from the global namespace, but runs only in the olm-microshift namespace. For MicroShift clusters that have network connectivity, Operator Lifecycle Manager (OLM) can access sources hosted on remote registries.

重要

All of the Operators installed in a specific namespace must have the same watch scope. In this case, the watch scope is OwnNamespace.

Prerequisites

  • The OpenShift CLI (oc) is installed.
  • Operator Lifecycle Manager (OLM) is installed.
  • You have created a custom catalog that is running in the global namespace.

Procedure

  1. Confirm that OLM is running by using the following command:

    $ oc -n openshift-operator-lifecycle-manager get pod -l app=olm-operator

    Example output

    NAME                           READY   STATUS    RESTARTS   AGE
    olm-operator-85b5c6786-n6kbc   1/1     Running   0          16m

  2. Confirm that the OLM catalog Operator is running by using the following command:

    $ oc -n openshift-operator-lifecycle-manager get pod -l app=catalog-operator

    Example output

    NAME                                READY   STATUS    RESTARTS   AGE
    catalog-operator-5fc7f857b6-tj8cf   1/1     Running   0          16m

  3. Create a namespace by using the following example YAML:

    Example namespace YAML

    apiVersion: v1
    kind: Namespace
    metadata:
      name: olm-microshift

  4. Apply the namespace configuration using the following command:

    $ oc apply -f _<ns.yaml>_ 
    1
    1
    Replace <ns.yaml> with the name of your namespace configuration file. In this example, olm-microshift is used.

    Example output

    namespace/olm-microshift created

  5. Create the Operator group YAML by using the following example YAML:

    Example Operator group YAML

    kind: OperatorGroup
    apiVersion: operators.coreos.com/v1
    metadata:
      name: og
      namespace: olm-microshift
    spec: 
    1
    
      targetNamespaces:
      - olm-microshift

    1
    For Operators using the global namespace, omit the spec.targetNamespaces field and values.
  6. Apply the Operator group configuration by running the following command:

    $ oc apply -f _<og.yaml>_ 
    1
    1
    Replace <og.yaml> with the name of your operator group configuration file.

    Example output

    operatorgroup.operators.coreos.com/og created

  7. Create the CatalogSource object by using the following example YAML:

    Example catalog source YAML

    apiVersion: operators.coreos.com/v1alpha1
    kind: CatalogSource
    metadata:
      name: operatorhubio-catalog
      namespace: openshift-marketplace 
    1
    
    spec:
      sourceType: grpc
      image: quay.io/operatorhubio/catalog:latest
      displayName: Community Operators 
    2
    
      publisher: OperatorHub.io
      grpcPodConfig:
        securityContextConfig: restricted 
    3
    
      updateStrategy:
        registryPoll:
          interval: 60m

    1
    The global namespace. Setting the metadata.namespace to openshift-marketplace enables the catalog to run in all namespaces. Subscriptions CRs in any namespace can reference catalogs created in the openshift-marketplace namespace.
    2
    Community Operators are not installed by default with OLM for MicroShift. Listed here for example only.
    3
    The value of securityContextConfig must be set to restricted for MicroShift.
  8. Apply the CatalogSource configuration by running the following command:

    $ oc apply -f _<my-catalog-source.yaml>_ 
    1
    1
    Replace <my-catalog-source.yaml> with your catalog source configuration file name.
  9. To verify that the catalog source is applied, check for the READY state by using the following command:

    $ oc describe catalogsources.operators.coreos.com -n openshift-marketplace operatorhubio-catalog

    Example output

    Name:         operatorhubio-catalog
    Namespace:    openshift-marketplace
    Labels:       <none>
    Annotations:  <none>
    API Version:  operators.coreos.com/v1alpha1
    Kind:         CatalogSource
    Metadata:
      Creation Timestamp:  2024-01-31T10:09:46Z
      Generation:          1
      Resource Version:    2811
      UID:                 60ce4a36-86d3-4921-b9fc-84d67c28df48
    Spec:
      Display Name:  Community Operators
      Grpc Pod Config:
        Security Context Config:  restricted
      Image:                      quay.io/operatorhubio/catalog:latest
      Publisher:                  OperatorHub.io
      Source Type:                grpc
      Update Strategy:
        Registry Poll:
          Interval:  60m
    Status:
      Connection State:
        Address:              operatorhubio-catalog.openshift-marketplace.svc:50051
        Last Connect:         2024-01-31T10:10:04Z
        Last Observed State:  READY 
    1
    
      Registry Service:
        Created At:         2024-01-31T10:09:46Z
        Port:               50051
        Protocol:           grpc
        Service Name:       operatorhubio-catalog
        Service Namespace:  openshift-marketplace
    Events:                 <none>

    1
    The status is reported as READY.
  10. Confirm that the catalog source is running by using the following command:

    $ oc get pods -n openshift-marketplace -l olm.catalogSource=operatorhubio-catalog

    Example output

    NAME                          READY   STATUS    RESTARTS   AGE
    operatorhubio-catalog-j7sc8   1/1     Running   0          43s

  11. Create a Subscription CR configuration file by using the following example YAML:

    Example Subscription custom resource YAML

    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: my-gitlab-operator-kubernetes
      namespace: olm-microshift 
    1
    
    spec:
      channel: stable
      name: gitlab-operator-kubernetes
      source: operatorhubio-catalog
      sourceNamespace: openshift-marketplace 
    2

    1
    The specific namespace. Operators reference the global namespace for content, but run in the olm-microshift namespace.
    2
    The global namespace. Subscriptions CRs in any namespace can reference catalogs created in the openshift-marketplace namespace.
  12. Apply the Subscription CR configuration by running the following command:

    $ oc apply -f _<my-subscription-cr.yaml>_

    Example output

    subscription.operators.coreos.com/my-gitlab-operator-kubernetes

  13. You can create a configuration file for the specific Operand you want to use and apply it now.

Verification

  1. Verify that your Operator is running by using the following command:

    $ oc get pods -n olm-microshift 
    1
    1
    The namespace from the Subscription CR is used.
    注記

    Allow a minute or two for the Operator start.

    Example output

    NAME                                         READY   STATUS    RESTARTS   AGE
    gitlab-controller-manager-69bb6df7d6-g7ntx   2/2     Running   0          3m24s

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

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

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

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

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

Legal Notice

Theme

© 2026 Red Hat
トップに戻る