|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * applications/operators/olm-adding-operators-to-cluster.adoc |
| 4 | + |
| 5 | +[id='olm-installing-operator-using-commands_{context}'] |
| 6 | + |
| 7 | += Installing an Operator using the command line |
| 8 | + |
| 9 | +Instead of using the {product-title} Web console, you can install an |
| 10 | +Operator from the command line. Use the `oc` command as follows to install |
| 11 | +(subscribe to) an Operator for a selected namespace. |
| 12 | + |
| 13 | +.Prerequisites |
| 14 | + |
| 15 | +- Access to an {product-title} 4 cluster using an account with `cluster-admin` |
| 16 | +permissions. |
| 17 | + |
| 18 | +.Procedure |
| 19 | + |
| 20 | +. To view a list of operators available from OperatorHub, type the following: |
| 21 | ++ |
| 22 | +---- |
| 23 | +$ oc get packagemanifest |
| 24 | +---- |
| 25 | + |
| 26 | +. To identify the Operators to install, create a CatalogSourceConfig object yaml file (for example, `csc.cr.yaml`) |
| 27 | +containing information similar to the following: |
| 28 | + |
| 29 | ++ |
| 30 | +.Example CatalogSourceConfig |
| 31 | +[source,yaml] |
| 32 | +---- |
| 33 | +apiVersion: "marketplace.redhat.com/v1alpha1" |
| 34 | +kind: "CatalogSourceConfig" |
| 35 | +metadata: |
| 36 | + name: "example" |
| 37 | + namespace: "openshift-marketplace" |
| 38 | +spec: |
| 39 | + targetNamespace: "global" <1> |
| 40 | + packages: "operators/myoperator,operators/another-operator" <2> |
| 41 | +---- |
| 42 | +<1> Set the `targetNamespace` to identify the namespace where you want the |
| 43 | +Operator to be available |
| 44 | +<2> Set `packages` to a comma-separated list of Operators to which |
| 45 | +you want to subscribe. |
| 46 | + |
| 47 | +. To install the Operator to the selected namespace, type the following: |
| 48 | ++ |
| 49 | +---- |
| 50 | +$ oc apply -f csc.cr.yaml |
| 51 | +---- |
| 52 | + |
| 53 | +. Later, if you want to install more operators, you can simply update your |
| 54 | +CatalogSourceConfig file (in this example, csc.cr.yaml) with more packages. |
| 55 | +For example: |
| 56 | ++ |
| 57 | +.Example updated CatalogSourceConfig |
| 58 | +[source,yaml] |
| 59 | +---- |
| 60 | +apiVersion: "marketplace.redhat.com/v1alpha1" |
| 61 | +kind: "CatalogSourceConfig" |
| 62 | +metadata: |
| 63 | + name: "example" |
| 64 | + namespace: "openshift-marketplace" |
| 65 | +spec: |
| 66 | + targetNamespace: "global" |
| 67 | + packages: "operators/myoperator,operators/another-operator,operators/this-operator-too" |
| 68 | + <1> |
| 69 | +---- |
| 70 | +<1> Add new packages to existing package list. |
| 71 | + |
| 72 | +. To update the CatalogSourceConfig object, run the `oc apply` command again: |
| 73 | ++ |
| 74 | +---- |
| 75 | +$ oc apply -f csc.cr.yaml |
| 76 | +---- |
| 77 | ++ |
| 78 | +The Operator will generate a CatalogSource and ConfigMap from your |
| 79 | +CatalogSourceConfig in the specified namespace (targetNamespace). |
| 80 | +With the OLM aware of your selected Operator, follow the OLM workflow |
| 81 | +to use the Operator. |
| 82 | + |
| 83 | +Before you can install your own Operators to cluster, you need to upload your |
| 84 | +Operator artifacts to Quay.io, then add your own `OperatorSource` to your |
| 85 | +cluster. Optionally, you can add Secrets to your Operator to provide authentication. The general steps for doing this are: |
| 86 | + |
| 87 | +. link:https://github.com/operator-framework/operator-marketplace/blob/master/docs/how-to-upload-artifact.md[Pushing an Operator Artifact to an App Registry] |
| 88 | +. link:https://github.com/operator-framework/operator-marketplace/blob/master/docs/how-to-authenticate-private-repositories.md[Authenticating Operators in your Private App Registry Repositories] |
| 89 | +. link:https://github.com/operator-framework/operator-marketplace/blob/master/README.md#populating-your-own-app-registry-operatorsource[Adding OperatorSource to your cluster] |
| 90 | + |
| 91 | + |
| 92 | +After that, you can manage the Operator in your |
| 93 | +cluster as you would any other Operator. |
0 commit comments