1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/microshift-olm-deploy-ops-global-ns.adoc
2025-11-06 15:07:52 +00:00

216 lines
6.7 KiB
Plaintext

//Module included in the following assemblies:
//
// * microshift_running_apps/microshift_operators/microshift-operators-olm.adoc
:_mod-docs-content-type: PROCEDURE
[id="microshift-OLM-deploy-Operators_{context}"]
= Adding OLM-based Operators to a networked node using the global namespace
[role="_abstract"]
To deploy different Operators to different namespaces, follow the basic steps to use configuration files to install an Operator that uses the global namespace.
For a {microshift-short} node that has network connectivity, Operator Lifecycle Manager (OLM) can access sources hosted on remote registries.
[NOTE]
====
To use an Operator installed in a different namespace, or in more than one namespace, make sure that both the catalog source and the Subscription CR that references the Operator are running in the `openshift-marketplace` namespace.
====
.Prerequisites
* The {oc-first} is installed.
* Operator Lifecycle Manager (OLM) is installed.
* You created a custom catalog in the global namespace.
.Procedure
. Confirm that OLM is running by using the following command:
+
[source,terminal]
----
$ oc -n openshift-operator-lifecycle-manager get pod -l app=olm-operator
----
+
.Example output
[source,terminal]
----
NAME READY STATUS RESTARTS AGE
olm-operator-85b5c6786-n6kbc 1/1 Running 0 2m24s
----
. Confirm that the OLM catalog Operator is running by using the following command:
+
[source,terminal]
----
$ oc -n openshift-operator-lifecycle-manager get pod -l app=catalog-operator
----
+
.Example output
[source,terminal]
----
NAME READY STATUS RESTARTS AGE
catalog-operator-5fc7f857b6-tj8cf 1/1 Running 0 2m33s
----
+
[NOTE]
====
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 `CatalogSource` object by using the following example YAML:
+
.Example catalog source YAML
[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-short}. Listed here for example only.
<3> The value of `securityContextConfig` must be set to `restricted` for {microshift-short}.
. Apply the `CatalogSource` configuration by running the following command:
+
[source,terminal,subs="+quotes"]
----
$ oc apply -f _<catalog_source.yaml>_ # <1>
----
<1> Replace `_<catalog_-_source.yaml>_` with your catalog source configuration file name. In this example, `catalogsource.yaml` is used.
+
.Example output
[source,terminal]
----
catalogsource.operators.coreos.com/operatorhubio-catalog created
----
. To verify that the catalog source is applied, check for the `READY` state by using the following command:
+
[source,terminal]
----
$ oc describe catalogsources.operators.coreos.com -n openshift-marketplace operatorhubio-catalog
----
+
.Example output
[source,terminal]
----
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`.
. Confirm that the catalog source is running by using the following command:
+
[source,terminal]
----
$ oc get pods -n openshift-marketplace -l olm.catalogSource=operatorhubio-catalog
----
+
.Example output
[source,terminal]
----
NAME READY STATUS RESTARTS AGE
operatorhubio-catalog-x24nh 1/1 Running 0 59s
----
. Create a Subscription CR configuration file by using the following example YAML:
+
.Example Subscription custom resource YAML
[source,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.
. Apply the Subscription CR configuration by running the following command:
+
[source,terminal,subs="+quotes"]
----
$ oc apply -f _<subscription_cr.yaml>_ # <1>
----
<1> Replace `_<subscription_cr.yaml>_` with your Subscription CR filename.
+
.Example output
[source,terminal]
----
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:
+
[source,terminal]
----
$ oc get pods -n openshift-operators <1>
----
<1> The namespace from the Subscription CR is used.
+
[NOTE]
====
Allow a minute or two for the Operator start.
====
+
.Example output
[source,terminal]
----
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
----