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
CatalogSourceadded to a cluster, so that the OLM catalog Operator can use the catalog for content.
-
Each catalog must have an accessible
You must use the CLI to conduct OLM activities with MicroShift. The console and OperatorHub GUIs are not available.
-
Use the Operator Package Manager
opmCLI with network-connected clusters, or for building catalogs for custom Operators that use an internal registry. - To mirror your catalogs and Operators for disconnected or offline clusters, install the oc-mirror OpenShift CLI plugin.
-
Use the Operator Package Manager
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.
-
You can install the
microshift-olmRPM at the same time you install the MicroShift RPM on Red Hat Enterprise Linux (RHEL). -
You can install the
microshift-olmon an existing MicroShift 4.16. Restart the MicroShift service after installing OLM for the changes to apply. See Installing the Operator Lifecycle Manager (OLM) from an RPM package. - You can embed OLM in a Red Hat Enterprise Linux for Edge (RHEL for Edge) image. See Adding the Operator Lifecycle Manager (OLM) service to a blueprint.
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.
| Default Namespace | Details |
|
| The OLM package manager runs in this namespace. |
|
|
The global namespace. Empty by default. To make the catalog source to be available globally to users in all namespaces, set the |
|
|
The default namespace where Operators run in MicroShift. Operators that reference catalogs in the |
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.
- For details, see Managing custom catalogs and Example catalog.
-
See also
opmCLI reference.
-
When adding a catalog source to a cluster, set the
securityContextConfigvalue torestrictedin thecatalogSource.yamlfile. Ensure that your catalog can run withrestrictedpermissions.
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
osbuildblueprint.
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
Confirm that OLM is running by using the following command:
$ oc -n openshift-operator-lifecycle-manager get pod -l app=olm-operatorExample output
NAME READY STATUS RESTARTS AGE olm-operator-85b5c6786-n6kbc 1/1 Running 0 2m24sConfirm that the OLM catalog Operator is running by using the following command:
$ oc -n openshift-operator-lifecycle-manager get pod -l app=catalog-operatorExample 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.
Create the
CatalogSourceobject by using the following example YAML:Example catalog source YAML
apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: operatorhubio-catalog namespace: openshift-marketplace1 spec: sourceType: grpc image: quay.io/operatorhubio/catalog:latest displayName: Community Operators2 publisher: OperatorHub.io grpcPodConfig: securityContextConfig: restricted3 updateStrategy: registryPoll: interval: 60m- 1
- The global namespace. Setting the
metadata.namespacetoopenshift-marketplaceenables the catalog to run in all namespaces. Subscriptions in any namespace can reference catalogs created in theopenshift-marketplacenamespace. - 2
- Community Operators are not installed by default with OLM for MicroShift. Listed here for example only.
- 3
- The value of
securityContextConfigmust be set torestrictedfor MicroShift.
Apply the
CatalogSourceconfiguration 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.yamlis used.
Example output
catalogsource.operators.coreos.com/operatorhubio-catalog createdTo verify that the catalog source is applied, check for the
READYstate by using the following command:$ oc describe catalogsources.operators.coreos.com -n openshift-marketplace operatorhubio-catalogExample 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: READY1 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.
Confirm that the catalog source is running by using the following command:
$ oc get pods -n openshift-marketplace -l olm.catalogSource=operatorhubio-catalogExample output
NAME READY STATUS RESTARTS AGE operatorhubio-catalog-x24nh 1/1 Running 0 59sCreate 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-marketplace1 - 1
- The global namespace. Setting the
sourceNamespacevalue toopenshift-marketplaceenables Operators to run in multiple namespaces if the catalog also runs in theopenshift-marketplacenamespace.
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.yamlis used.
Example output
subscription.operators.coreos.com/my-cert-manager created- You can create a configuration file for the specific Operand you want to use and apply it now.
Verification
Verify that your Operator is running by using the following command:
$ oc get pods -n openshift-operators1 - 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
Confirm that OLM is running by using the following command:
$ oc -n openshift-operator-lifecycle-manager get pod -l app=olm-operatorExample output
NAME READY STATUS RESTARTS AGE olm-operator-85b5c6786-n6kbc 1/1 Running 0 16mConfirm that the OLM catalog Operator is running by using the following command:
$ oc -n openshift-operator-lifecycle-manager get pod -l app=catalog-operatorExample output
NAME READY STATUS RESTARTS AGE catalog-operator-5fc7f857b6-tj8cf 1/1 Running 0 16mCreate a namespace by using the following example YAML:
Example namespace YAML
apiVersion: v1 kind: Namespace metadata: name: olm-microshiftApply 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-microshiftis used.
Example output
namespace/olm-microshift createdCreate 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.targetNamespacesfield and values.
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 createdCreate the
CatalogSourceobject by using the following example YAML:Example catalog source YAML
apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: operatorhubio-catalog namespace: openshift-marketplace1 spec: sourceType: grpc image: quay.io/operatorhubio/catalog:latest displayName: Community Operators2 publisher: OperatorHub.io grpcPodConfig: securityContextConfig: restricted3 updateStrategy: registryPoll: interval: 60m- 1
- The global namespace. Setting the
metadata.namespacetoopenshift-marketplaceenables the catalog to run in all namespaces. Subscriptions CRs in any namespace can reference catalogs created in theopenshift-marketplacenamespace. - 2
- Community Operators are not installed by default with OLM for MicroShift. Listed here for example only.
- 3
- The value of
securityContextConfigmust be set torestrictedfor MicroShift.
Apply the
CatalogSourceconfiguration 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.
To verify that the catalog source is applied, check for the
READYstate by using the following command:$ oc describe catalogsources.operators.coreos.com -n openshift-marketplace operatorhubio-catalogExample 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: READY1 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.
Confirm that the catalog source is running by using the following command:
$ oc get pods -n openshift-marketplace -l olm.catalogSource=operatorhubio-catalogExample output
NAME READY STATUS RESTARTS AGE operatorhubio-catalog-j7sc8 1/1 Running 0 43sCreate 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-microshift1 spec: channel: stable name: gitlab-operator-kubernetes source: operatorhubio-catalog sourceNamespace: openshift-marketplace2 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- You can create a configuration file for the specific Operand you want to use and apply it now.
Verification
Verify that your Operator is running by using the following command:
$ oc get pods -n olm-microshift1 - 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