diff --git a/docs/howto/catalog-queries.md b/docs/howto/catalog-queries.md index c58a7bff1..91314acdd 100644 --- a/docs/howto/catalog-queries.md +++ b/docs/howto/catalog-queries.md @@ -1,73 +1,108 @@ # Catalog queries +After you [add a catalog of extensions](../tutorials/add-catalog.md) to your cluster, you must port forward your catalog as a service. +Then you can query the catalog by using `curl` commands and the `jq` CLI tool to find extensions to install. + +## Prerequisites + +* You have added a ClusterCatalog of extensions, such as [OperatorHub.io](https://operatorhub.io), to your cluster. +* You have installed the `jq` CLI tool. + !!! note By default, Catalogd is installed with TLS enabled for the catalog webserver. The following examples will show this default behavior, but for simplicity's sake will ignore TLS verification in the curl commands using the `-k` flag. +You also need to port forward the catalog server service: + +``` terminal +kubectl -n olmv1-system port-forward svc/catalogd-service 8443:443 +``` -You can use the `curl` command with `jq` to query catalogs that are installed on your cluster. +Now you can use the `curl` command with `jq` to query catalogs that are installed on your cluster. ``` terminal title="Query syntax" curl -k https://localhost:8443/catalogs/operatorhubio/api/v1/all | ``` +`` +: One of the `jq` queries from this document ## Package queries -Available packages in a catalog -: -``` terminal -jq -s '.[] | select( .schema == "olm.package")' -``` +* Available packages in a catalog: + ``` terminal + jq -s '.[] | select( .schema == "olm.package")' + ``` -Packages that support `AllNamespaces` install mode and do not use webhooks +* Packages that support `AllNamespaces` install mode and do not use webhooks: + ``` 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}' + ``` -: -``` 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}' -``` +* Package metadata: + ``` terminal + jq -s '.[] | select( .schema == "olm.package") | select( .name == "")' + ``` -Package metadata -: -``` terminal -jq -s '.[] | select( .schema == "olm.package") | select( .name == "")' -``` + `` + : Name of the package from the catalog you are querying. -Catalog blobs in a package -: -``` terminal -jq -s '.[] | select( .package == "")' -``` +* Catalog blobs in a package: + ``` terminal + jq -s '.[] | select( .package == "")' + ``` + + `` + : Name of the package from the catalog you are querying. ## Channel queries -Channels in a package -: -``` terminal -jq -s '.[] | select( .schema == "olm.channel" ) | select( .package == "") | .name' -``` +* Channels in a package: + ``` terminal + jq -s '.[] | select( .schema == "olm.channel" ) | select( .package == "") | .name' + ``` -Versions in a channel -: -``` terminal -jq -s '.[] | select( .package == "" ) | select( .schema == "olm.channel" ) | select( .name == "" ) | .entries | .[] | .name' -``` + `` + : Name of the package from the catalog you are querying. -Latest version in a channel and upgrade path -: -``` terminal -jq -s '.[] | select( .schema == "olm.channel" ) | select ( .name == "") | select( .package == "")' -``` +* Versions in a channel: + ``` terminal + jq -s '.[] | select( .package == "" ) | select( .schema == "olm.channel" ) | select( .name == "" ) | .entries | .[] | .name' + ``` + + `` + : Name of the package from the catalog you are querying. + + `` + : Name of the channel for a given package. + +* Latest version in a channel and upgrade path: + ``` terminal + jq -s '.[] | select( .schema == "olm.channel" ) | select ( .name == "") | select( .package == "")' + ``` + + `` + : Name of the package from the catalog you are querying. + + `` + : Name of the channel for a given package. ## Bundle queries -Bundles in a package -: -``` terminal -jq -s '.[] | select( .schema == "olm.bundle" ) | select( .package == "") | .name' -``` +* Bundles in a package: + ``` terminal + jq -s '.[] | select( .schema == "olm.bundle" ) | select( .package == "") | .name' + ``` -Bundle dependencies and available APIs -: -``` terminal -jq -s '.[] | select( .schema == "olm.bundle" ) | select ( .name == "") | select( .package == "")' -``` + `` + : Name of the package from the catalog you are querying. + +* Bundle dependencies and available APIs: + ``` terminal + jq -s '.[] | select( .schema == "olm.bundle" ) | select ( .name == "") | select( .package == "")' + ``` + + `` + : Name of the package from the catalog you are querying. + + `` + : Name of the bundle for a given package.