diff --git a/modules/olmv1-catalog-queries.adoc b/modules/olmv1-catalog-queries.adoc index 7c4f703bd8..8c62edb7b1 100644 --- a/modules/olmv1-catalog-queries.adoc +++ b/modules/olmv1-catalog-queries.adoc @@ -7,7 +7,33 @@ [id="olmv1-catalog-queries_{context}"] = Common catalog queries -You can query catalogs by using the `jq` CLI tool. +You can query catalogs by using the `opm` and `jq` CLI tools. The following tables show common catalog queries that you can use when installing, updating, and managing the lifecycle of extensions. + +.Command syntax +[source,terminal] +---- +$ opm render : | +---- +where: + +`catalog_registry_url`:: Specifies the URL of the catalog registry, such as `registry.redhat.io/redhat/redhat-operator-index`. +`tag`:: Specifies the tag or version of the catalog, such as `v{product-version}` or `latest`. +`jq_request`:: Specifies the query you want to run on the catalog. + +.Example command +[%collapsible] +==== +[source,terminal,subs=attributes+] +---- +$ opm render \ + registry.redhat.io/redhat/redhat-operator-index:v{product-version} \ + | jq -cs '[.[] | select(.schema == "olm.bundle" and (.properties[] \ + | select(.type == "olm.csv.metadata").value.installModes[] \ + | select(.type == "AllNamespaces" and .supported == true)) \ + and .spec.webhookdefinitions == null) \ + | .package] | unique[]' +---- +==== // https://docs.asciidoctor.org/asciidoc/latest/tables/format-cell-content/#a-operator // https://docs.asciidoctor.org/asciidoc/latest/tables/data-format/#escape-the-cell-separator @@ -20,38 +46,37 @@ You can query catalogs by using the `jq` CLI tool. a| [source,terminal] ---- -$ jq -s '.[] \| select( .schema == "olm.package") \| \ - .name' .json +$ opm render : \ + \| jq -s '.[] \| select( .schema == "olm.package") ---- |Packages that support `AllNamespaces` install mode and do not use webhooks a| [source,terminal] ---- -$ jq -c 'select(.schema == "olm.bundle") \| \ - {"package":.package, "version":.properties[] \| \ - select(.type == "olm.bundle.object").value.data \| \ - @base64d \| fromjson \| \ - select(.kind == "ClusterServiceVersion" and (.spec.installModes[] \| \ - select(.type == "AllNamespaces" and .supported == true) != null) \ - and .spec.webhookdefinitions == null).spec.version}' \ - .json +$ opm render : \ + \| jq -cs '[.[] \| select(.schema == "olm.bundle" and (.properties[] \ + \| select(.type == "olm.csv.metadata").value.installModes[] \ + \| select(.type == "AllNamespaces" and .supported == true)) \ + and .spec.webhookdefinitions == null) \ + \| .package] \| unique[]' ---- |Package metadata a| [source,terminal] ---- -$ jq -s '.[] \| select( .schema == "olm.package") \| \ - select( .name == "")' .json +$ opm render : \ + \| jq -s '.[] \| select( .schema == "olm.package") \ + \| select( .name == "")' ---- |Catalog blobs in a package a| [source,terminal] ---- -$ jq -s '.[] \| select( .package == "")' \ - .json +$ opm render : \ + \| jq -s '.[] \| select( .package == "")' ---- |=== @@ -65,19 +90,20 @@ $ jq -s '.[] \| select( .package == "")' \ a| [source,terminal] ---- -$ jq -s '.[] \| select( .schema == "olm.channel" ) \| \ - select( .package == "") \| .name' \ - .json +$ opm render : \ + \| jq -s '.[] \| select( .schema == "olm.channel" ) \ + \| select( .package == "") \| .name' ---- |Versions in a channel a| [source,terminal] ---- -$ jq -s '.[] \| select( .package == "" ) \| \ - select( .schema == "olm.channel" ) \| \ - select( .name == "" ) \| \ - .entries \| .[] \| .name' .json +$ opm render : \ + \| jq -s '.[] \| select( .package == "" ) \ + \| select( .schema == "olm.channel" ) \ + \| select( .name == "" ) .entries \ + \| .[] \| .name' ---- a| @@ -86,10 +112,10 @@ a| a| [source,terminal] ---- -$ jq -s '.[] \| select( .schema == "olm.channel" ) \| \ - select ( .name == "") \| \ - select( .package == "")' \ - .json +$ opm render : \ + \| jq -s '.[] \| select( .schema == "olm.channel" ) \ + \| select ( .name == "") \ + \| select( .package == "")' ---- |=== @@ -103,9 +129,9 @@ $ jq -s '.[] \| select( .schema == "olm.channel" ) \| \ a| [source,terminal] ---- -$ jq -s '.[] \| select( .schema == "olm.bundle" ) \| \ - select( .package == "") \| .name' \ - .json +$ opm render : \ + \| jq -s '.[] \| select( .schema == "olm.bundle" ) \ + \| select( .package == "") \| .name' ---- a| @@ -114,10 +140,10 @@ a| a| [source,terminal] ---- -$ jq -s '.[] \| select( .schema == "olm.bundle" ) \| \ - select ( .name == "") \| \ - select( .package == "")' \ - .json +$ opm render : \ + \| jq -s '.[] \| select( .schema == "olm.bundle" ) \ + \| select ( .name == "") \ + \| select( .package == "")' ---- |=== diff --git a/modules/olmv1-finding-operators-to-install.adoc b/modules/olmv1-finding-operators-to-install.adoc index ba03ebebc7..d337759d18 100644 --- a/modules/olmv1-finding-operators-to-install.adoc +++ b/modules/olmv1-finding-operators-to-install.adoc @@ -7,62 +7,44 @@ [id="olmv1-finding-operators-to-install_{context}"] = Finding Operators to install from a catalog -After you add a catalog to your cluster, you can query the catalog to find Operators and extensions to install. Before you can query catalogs, you must port forward the catalog server service. +After you add a catalog to your cluster, you can query the catalog to find Operators and extensions to install. + +include::snippets/olmv1-on-cluster-catalog-queries.adoc[] .Prerequisites * You have added a catalog to your cluster. * You have installed the `jq` CLI tool. +* You have installed the `opm` CLI tool. .Procedure -. Port forward the catalog server service in the `openshift-catalogd` namespace by running the following command: +. To return a list of extensions that support the `AllNamespaces` install mode and do not use webhooks, enter the following command: + [source,terminal] ---- -$ oc -n openshift-catalogd port-forward svc/catalogd-catalogserver 8080:443 +$ opm render : \ + | jq -cs '[.[] | select(.schema == "olm.bundle" \ + and (.properties[] | select(.type == "olm.csv.metadata").value.installModes[] \ + | select(.type == "AllNamespaces" and .supported == true)) \ + and .spec.webhookdefinitions == null) | .package] | unique[]' ---- +where: -. In a new terminal window or tab, download the catalog's JSON file locally by running the following command: -+ -[source,terminal] ----- -$ curl -L -k https://localhost:8080/catalogs//all.json \ - -C - -o //.json ----- +`catalog_registry_url`:: Specifies the URL of the catalog registry, such as `registry.redhat.io/redhat/redhat-operator-index`. +`tag`:: Specifies the tag or version of the catalog, such as `v{product-version}` or `latest`. + .Example command [%collapsible] ==== -[source,terminal] +[source,terminal,subs=attributes+] ---- -$ curl -L -k https://localhost:8080/catalogs/redhat-operators/all.json \ - -C - -o /home/username/catalogs/rhoc.json ----- -==== - -. Run one of the following commands to return a list of Operators and extensions in a catalog. -+ -[IMPORTANT] -==== -include::snippets/olmv1-tp-extension-support.adoc[] -==== -+ -* Get a list of all the Operators and extensions from the local catalog file by running the following command: -+ -[source,terminal] ----- -$ jq -s '.[] | select(.schema == "olm.package") | .name' \ - //.json ----- -+ -.Example command -[%collapsible] -==== -[source,terminal] ----- -$ jq -s '.[] | select(.schema == "olm.package") | .name' \ - /home/username/catalogs/rhoc.json +$ opm render \ + registry.redhat.io/redhat/redhat-operator-index:v{product-version} \ + | jq -cs '[.[] | select(.schema == "olm.bundle" \ + and (.properties[] | select(.type == "olm.csv.metadata").value.installModes[] \ + | select(.type == "AllNamespaces" and .supported == true)) \ + and .spec.webhookdefinitions == null) | .package] | unique[]' ---- ==== + @@ -71,82 +53,48 @@ $ jq -s '.[] | select(.schema == "olm.package") | .name' \ ==== [source,text] ---- -NAME AGE "3scale-operator" -"advanced-cluster-management" "amq-broker-rhel8" "amq-online" "amq-streams" -"amq7-interconnect-operator" +"amq-streams-console" "ansible-automation-platform-operator" "ansible-cloud-addons-operator" "apicast-operator" -"aws-efs-csi-driver-operator" +"authorino-operator" "aws-load-balancer-operator" -"bamoe-businessautomation-operator" "bamoe-kogito-operator" -"bare-metal-event-relay" -"businessautomation-operator" -... ----- -==== -+ -* Get list of packages that support `AllNamespaces` install mode and do not use webhooks from the local catalog file by running the following command: -+ -[source,terminal] ----- -$ jq -c 'select(.schema == "olm.bundle") | \ - {"package":.package, "version":.properties[] | \ - select(.type == "olm.bundle.object").value.data | @base64d | fromjson | \ - select(.kind == "ClusterServiceVersion" and (.spec.installModes[] | \ - select(.type == "AllNamespaces" and .supported == true) != null) \ - and .spec.webhookdefinitions == null).spec.version}' \ - //.json ----- -+ -.Example output -[%collapsible] -==== -[source,text] ----- -{"package":"3scale-operator","version":"0.10.0-mas"} -{"package":"3scale-operator","version":"0.10.5"} -{"package":"3scale-operator","version":"0.11.0-mas"} -{"package":"3scale-operator","version":"0.11.1-mas"} -{"package":"3scale-operator","version":"0.11.2-mas"} -{"package":"3scale-operator","version":"0.11.3-mas"} -{"package":"3scale-operator","version":"0.11.5-mas"} -{"package":"3scale-operator","version":"0.11.6-mas"} -{"package":"3scale-operator","version":"0.11.7-mas"} -{"package":"3scale-operator","version":"0.11.8-mas"} -{"package":"amq-broker-rhel8","version":"7.10.0-opr-1"} -{"package":"amq-broker-rhel8","version":"7.10.0-opr-2"} -{"package":"amq-broker-rhel8","version":"7.10.0-opr-3"} -{"package":"amq-broker-rhel8","version":"7.10.0-opr-4"} -{"package":"amq-broker-rhel8","version":"7.10.1-opr-1"} -{"package":"amq-broker-rhel8","version":"7.10.1-opr-2"} -{"package":"amq-broker-rhel8","version":"7.10.2-opr-1"} -{"package":"amq-broker-rhel8","version":"7.10.2-opr-2"} +"cephcsi-operator" +"cincinnati-operator" +"cluster-logging" +"cluster-observability-operator" +"compliance-operator" +"container-security-operator" +"cryostat-operator" +"datagrid" +"devspaces" ... ---- ==== -. Inspect the contents of an Operator or extension's metadata by running the following command: +. Inspect the contents of an extension's metadata by running the following command: + [source,terminal] ---- -$ jq -s '.[] | select( .schema == "olm.package") | \ - select( .name == "")' //.json +$ opm render : \ + | jq -s '.[] | select( .schema == "olm.package") \ + | select( .name == "")' ---- + .Example command [%collapsible] ==== -[source,terminal] +[source,terminal,subs=attributes+] ---- -$ jq -s '.[] | select( .schema == "olm.package") | \ - select( .name == "openshift-pipelines-operator-rh")' \ - /home/username/rhoc.json +$ opm render \ + registry.redhat.io/redhat/redhat-operator-index:v{product-version} \ + | jq -s '.[] | select( .schema == "olm.package") \ + | select( .name == "openshift-pipelines-operator-rh")' ---- ==== + @@ -156,13 +104,13 @@ $ jq -s '.[] | select( .schema == "olm.package") | \ [source,text] ---- { - "defaultChannel": "stable", - "icon": { - "base64data": "PHN2ZyB4bWxu..." - "mediatype": "image/png" - }, + "schema": "olm.package", "name": "openshift-pipelines-operator-rh", - "schema": "olm.package" + "defaultChannel": "latest", + "icon": { + "base64data": "iVBORw0KGgoAAAANSUhE...", + "mediatype": "image/png" + } } ---- ==== diff --git a/modules/olmv1-installing-an-operator.adoc b/modules/olmv1-installing-an-operator.adoc index 6cc9da2312..fae57b8e1d 100644 --- a/modules/olmv1-installing-an-operator.adoc +++ b/modules/olmv1-installing-an-operator.adoc @@ -11,10 +11,9 @@ You can install an extension from a catalog by creating a custom resource (CR) a .Prerequisites -* You have added a catalog to your cluster. -* You have downloaded a local copy of the catalog file. * You have installed the `jq` CLI tool. -* You have created a service account and assigned enough role-based access controls (RBAC) to install, update, and manage the extension you want to install. For more information, see _Creating a service account_. +* You have installed the `opm` CLI tool. +* You have created a service account and assigned enough role-based access controls (RBAC) to install, update, and manage the extension you want to install. For more information, see "Creating a service account to manage cluster extensions". .Procedure @@ -24,19 +23,21 @@ You can install an extension from a catalog by creating a custom resource (CR) a + [source,terminal] ---- -$ jq -s '.[] | select( .schema == "olm.channel" ) | \ - select( .package == "") | \ - .name' //.json +$ opm render : \ + | jq -s '.[] | select( .schema == "olm.channel" ) \ + | select( .package == "") \ + | .name' ---- + .Example command [%collapsible] ==== -[source,terminal] +[source,terminal,subs=attributes+] ---- -$ jq -s '.[] | select( .schema == "olm.channel" ) | \ - select( .package == "openshift-pipelines-operator-rh") | \ - .name' /home/username/rhoc.json +$ opm render registry.redhat.io/redhat/redhat-operator-index:v{product-version} \ + | jq -s '.[] | select( .schema == "olm.channel" ) \ + | select( .package == "openshift-pipelines-operator-rh") \ + | .name' ---- ==== + @@ -46,10 +47,9 @@ $ jq -s '.[] | select( .schema == "olm.channel" ) | \ [source,text] ---- "latest" -"pipelines-1.11" -"pipelines-1.12" -"pipelines-1.13" "pipelines-1.14" +"pipelines-1.15" +"pipelines-1.16" ---- ==== @@ -57,20 +57,22 @@ $ jq -s '.[] | select( .schema == "olm.channel" ) | \ + [source,terminal] ---- -$ jq -s '.[] | select( .package == "" ) | \ - select( .schema == "olm.channel" ) | \ - select( .name == "" ) | .entries | \ - .[] | .name' //.json +$ opm render : \ + | jq -s '.[] | select( .package == "" ) \ + | select( .schema == "olm.channel" ) \ + | select( .name == "" ) | .entries \ + | .[] | .name' ---- + .Example command [%collapsible] ==== -[source,terminal] +[source,terminal,subs=attributes+] ---- -$ jq -s '.[] | select( .package == "openshift-pipelines-operator-rh" ) | \ -select( .schema == "olm.channel" ) | select( .name == "latest" ) | \ -.entries | .[] | .name' /home/username/rhoc.json +$ opm render registry.redhat.io/redhat/redhat-operator-index:v{product-version} \ + | jq -s '.[] | select( .package == "openshift-pipelines-operator-rh" ) \ + | select( .schema == "olm.channel" ) | select( .name == "latest" ) \ + | .entries | .[] | .name' ---- ==== + @@ -79,23 +81,17 @@ select( .schema == "olm.channel" ) | select( .name == "latest" ) | \ ==== [source,text] ---- -"openshift-pipelines-operator-rh.v1.12.0" -"openshift-pipelines-operator-rh.v1.12.1" -"openshift-pipelines-operator-rh.v1.12.2" -"openshift-pipelines-operator-rh.v1.13.0" -"openshift-pipelines-operator-rh.v1.13.1" -"openshift-pipelines-operator-rh.v1.11.1" -"openshift-pipelines-operator-rh.v1.12.0" -"openshift-pipelines-operator-rh.v1.12.1" -"openshift-pipelines-operator-rh.v1.12.2" -"openshift-pipelines-operator-rh.v1.13.0" -"openshift-pipelines-operator-rh.v1.14.1" -"openshift-pipelines-operator-rh.v1.14.2" "openshift-pipelines-operator-rh.v1.14.3" "openshift-pipelines-operator-rh.v1.14.4" - +"openshift-pipelines-operator-rh.v1.14.5" +"openshift-pipelines-operator-rh.v1.15.0" +"openshift-pipelines-operator-rh.v1.15.1" +"openshift-pipelines-operator-rh.v1.15.2" +"openshift-pipelines-operator-rh.v1.16.0" +"openshift-pipelines-operator-rh.v1.16.1" ---- ==== + . If you want to install your extension into a new namespace, run the following command: + [source,terminal] diff --git a/snippets/olmv1-on-cluster-catalog-queries.adoc b/snippets/olmv1-on-cluster-catalog-queries.adoc new file mode 100644 index 0000000000..164f6b50b5 --- /dev/null +++ b/snippets/olmv1-on-cluster-catalog-queries.adoc @@ -0,0 +1,7 @@ +// Text snippet included in the following modules: +// +// * olmv1-finding-operators-to-install.adoc + +:_mod-docs-content-type: SNIPPET + +Currently in {olmv1-first}, you cannot query on-cluster catalogs managed by catalogd. In OLM v1, you must use the `opm` and `jq` CLI tools to query the catalog registry.