|
1 | 1 | # Catalog queries
|
2 | 2 |
|
| 3 | +After you [add a catalog of extensions](../tutorials/add-catalog.md) to your cluster, you must port forward your catalog as a service. |
| 4 | +Then you can query the catalog by using `curl` commands and the `jq` CLI tool to find extensions to install. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +* You have added a ClusterCatalog of extensions, such as [OperatorHub.io](https://operatorhub.io), to your cluster. |
| 9 | +* You have installed the `jq` CLI tool. |
| 10 | + |
3 | 11 | !!! note
|
4 | 12 | By default, Catalogd is installed with TLS enabled for the catalog webserver.
|
5 | 13 | 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.
|
6 | 14 |
|
| 15 | +You also need to port forward the catalog server service: |
| 16 | + |
| 17 | +``` terminal |
| 18 | +kubectl -n olmv1-system port-forward svc/catalogd-service 8443:443 |
| 19 | +``` |
7 | 20 |
|
8 |
| -You can use the `curl` command with `jq` to query catalogs that are installed on your cluster. |
| 21 | +Now you can use the `curl` command with `jq` to query catalogs that are installed on your cluster. |
9 | 22 |
|
10 | 23 | ``` terminal title="Query syntax"
|
11 | 24 | curl -k https://localhost:8443/catalogs/operatorhubio/api/v1/all | <query>
|
12 | 25 | ```
|
| 26 | +`<query>` |
| 27 | +: One of the `jq` queries from this document |
13 | 28 |
|
14 | 29 | ## Package queries
|
15 | 30 |
|
16 |
| -Available packages in a catalog |
17 |
| -: |
18 |
| -``` terminal |
19 |
| -jq -s '.[] | select( .schema == "olm.package")' |
20 |
| -``` |
| 31 | +* Available packages in a catalog: |
| 32 | + ``` terminal |
| 33 | + jq -s '.[] | select( .schema == "olm.package")' |
| 34 | + ``` |
21 | 35 |
|
22 |
| -Packages that support `AllNamespaces` install mode and do not use webhooks |
| 36 | +* Packages that support `AllNamespaces` install mode and do not use webhooks: |
| 37 | + ``` terminal |
| 38 | + 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}' |
| 39 | + ``` |
23 | 40 |
|
24 |
| -: |
25 |
| -``` terminal |
26 |
| -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}' |
27 |
| -``` |
| 41 | +* Package metadata: |
| 42 | + ``` terminal |
| 43 | + jq -s '.[] | select( .schema == "olm.package") | select( .name == "<package_name>")' |
| 44 | + ``` |
28 | 45 |
|
29 |
| -Package metadata |
30 |
| -: |
31 |
| -``` terminal |
32 |
| -jq -s '.[] | select( .schema == "olm.package") | select( .name == "<package_name>")' |
33 |
| -``` |
| 46 | + `<package_name>` |
| 47 | + : Name of the package from the catalog you are querying. |
34 | 48 |
|
35 |
| -Catalog blobs in a package |
36 |
| -: |
37 |
| -``` terminal |
38 |
| -jq -s '.[] | select( .package == "<package_name>")' |
39 |
| -``` |
| 49 | +* Catalog blobs in a package: |
| 50 | + ``` terminal |
| 51 | + jq -s '.[] | select( .package == "<package_name>")' |
| 52 | + ``` |
| 53 | +
|
| 54 | + `<package_name>` |
| 55 | + : Name of the package from the catalog you are querying. |
40 | 56 |
|
41 | 57 | ## Channel queries
|
42 | 58 |
|
43 |
| -Channels in a package |
44 |
| -: |
45 |
| -``` terminal |
46 |
| -jq -s '.[] | select( .schema == "olm.channel" ) | select( .package == "<package_name>") | .name' |
47 |
| -``` |
| 59 | +* Channels in a package: |
| 60 | + ``` terminal |
| 61 | + jq -s '.[] | select( .schema == "olm.channel" ) | select( .package == "<package_name>") | .name' |
| 62 | + ``` |
48 | 63 |
|
49 |
| -Versions in a channel |
50 |
| -: |
51 |
| -``` terminal |
52 |
| -jq -s '.[] | select( .package == "<package_name>" ) | select( .schema == "olm.channel" ) | select( .name == "<channel_name>" ) | .entries | .[] | .name' |
53 |
| -``` |
| 64 | + `<package_name>` |
| 65 | + : Name of the package from the catalog you are querying. |
54 | 66 |
|
55 |
| -Latest version in a channel and upgrade path |
56 |
| -: |
57 |
| -``` terminal |
58 |
| -jq -s '.[] | select( .schema == "olm.channel" ) | select ( .name == "<channel>") | select( .package == "<package_name>")' |
59 |
| -``` |
| 67 | +* Versions in a channel: |
| 68 | + ``` terminal |
| 69 | + jq -s '.[] | select( .package == "<package_name>" ) | select( .schema == "olm.channel" ) | select( .name == "<channel_name>" ) | .entries | .[] | .name' |
| 70 | + ``` |
| 71 | +
|
| 72 | + `<package_name>` |
| 73 | + : Name of the package from the catalog you are querying. |
| 74 | +
|
| 75 | + `<channel_name>` |
| 76 | + : Name of the channel for a given package. |
| 77 | +
|
| 78 | +* Latest version in a channel and upgrade path: |
| 79 | + ``` terminal |
| 80 | + jq -s '.[] | select( .schema == "olm.channel" ) | select ( .name == "<channel_name>") | select( .package == "<package_name>")' |
| 81 | + ``` |
| 82 | +
|
| 83 | + `<package_name>` |
| 84 | + : Name of the package from the catalog you are querying. |
| 85 | +
|
| 86 | + `<channel_name>` |
| 87 | + : Name of the channel for a given package. |
60 | 88 |
|
61 | 89 | ## Bundle queries
|
62 | 90 |
|
63 |
| -Bundles in a package |
64 |
| -: |
65 |
| -``` terminal |
66 |
| -jq -s '.[] | select( .schema == "olm.bundle" ) | select( .package == "<package_name>") | .name' |
67 |
| -``` |
| 91 | +* Bundles in a package: |
| 92 | + ``` terminal |
| 93 | + jq -s '.[] | select( .schema == "olm.bundle" ) | select( .package == "<package_name>") | .name' |
| 94 | + ``` |
68 | 95 |
|
69 |
| -Bundle dependencies and available APIs |
70 |
| -: |
71 |
| -``` terminal |
72 |
| -jq -s '.[] | select( .schema == "olm.bundle" ) | select ( .name == "<bundle_name>") | select( .package == "<package_name>")' |
73 |
| -``` |
| 96 | + `<package_name>` |
| 97 | + : Name of the package from the catalog you are querying. |
| 98 | +
|
| 99 | +* Bundle dependencies and available APIs: |
| 100 | + ``` terminal |
| 101 | + jq -s '.[] | select( .schema == "olm.bundle" ) | select ( .name == "<bundle_name>") | select( .package == "<package_name>")' |
| 102 | + ``` |
| 103 | +
|
| 104 | + `<package_name>` |
| 105 | + : Name of the package from the catalog you are querying. |
| 106 | +
|
| 107 | + `<bundle_name>` |
| 108 | + : Name of the bundle for a given package. |
0 commit comments