5.2. 管理集群扩展
您可以使用目录访问扩展和 Operator 的版本、补丁和无线更新。您可以使用自定义资源(CR)从 CLI 声明性管理扩展。
对于 OpenShift Container Platform 4.22,记录的 OLM v1 的步骤仅基于 CLI。另外,管理员也可以使用普通方法(如 Import YAML 和 Search 页面)在 web 控制台中创建和查看相关对象。但是,现有的 Software Catalog 和 Installed Operators 页还不会显示 OLM v1 组件。
5.2.1. 从目录查找 Operator 复制链接链接已复制到粘贴板!
在集群中添加目录后,您可以查询目录以查找要安装的 Operator 和扩展。
目前,在 Operator Lifecycle Manager (OLM) v1 中,您无法查询由 catalogd 管理的集群目录。在 OLM v1 中,您必须使用 opm 和 jq CLI 工具查询目录 registry。
先决条件
- 您已在集群中添加目录。
-
已安装
jqCLI 工具。 -
已安装
opmCLI 工具。
流程
要返回支持
AllNamespaces安装模式的扩展列表,且不使用 Webhook,请输入以下命令:$ opm render <catalog_registry_url>:<tag> \ | 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[]'其中:
catalog_registry_url-
指定目录 registry 的 URL,如
registry.redhat.io/redhat/redhat-operator-index。 tag指定目录的标签或版本,如
v4.22或latest。例 5.1. 示例命令
$ opm render \ registry.redhat.io/redhat/redhat-operator-index:v4.22 \ | 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[]'例 5.2. 输出示例
"3scale-operator" "amq-broker-rhel8" "amq-online" "amq-streams" "amq-streams-console" "ansible-automation-platform-operator" "ansible-cloud-addons-operator" "apicast-operator" "authorino-operator" "aws-load-balancer-operator" "bamoe-kogito-operator" "cephcsi-operator" "cincinnati-operator" "cluster-logging" "cluster-observability-operator" "compliance-operator" "container-security-operator" "cryostat-operator" "datagrid" "devspaces" ...
运行以下命令,检查扩展的元数据内容:
$ opm render <catalog_registry_url>:<tag> \ | jq -s '.[] | select( .schema == "olm.package") \ | select( .name == "<package_name>")'例 5.3. 示例命令
$ opm render \ registry.redhat.io/redhat/redhat-operator-index:v4.22 \ | jq -s '.[] | select( .schema == "olm.package") \ | select( .name == "openshift-pipelines-operator-rh")'例 5.4. 输出示例
{ "schema": "olm.package", "name": "openshift-pipelines-operator-rh", "defaultChannel": "latest", "icon": { "base64data": "iVBORw0KGgoAAAANSUhE...", "mediatype": "image/png" } }
5.2.1.1. 常见目录查询 复制链接链接已复制到粘贴板!
您可以使用 opm 和 jq CLI 工具查询目录。下表显示了您可以在安装、更新和管理扩展生命周期时使用的通用目录查询。
命令语法
$ opm render <catalog_registry_url>:<tag> | <jq_request>
其中:
catalog_registry_url-
指定目录 registry 的 URL,如
registry.redhat.io/redhat/redhat-operator-index。 tag-
指定目录的标签或版本,如
v4.22或latest。 jq_request- 指定您要在目录上运行的查询。
例 5.5. 示例命令
$ opm render \
registry.redhat.io/redhat/redhat-operator-index:v4.22 \
| 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[]'
| 查询 | Request(请求) |
|---|---|
| 目录中的可用软件包 |
|
|
支持 |
|
| 软件包元数据 |
|
| 软件包中的目录 Blob |
|
| 查询 | Request(请求) |
|---|---|
| 软件包中的频道 |
|
| 频道中的版本 |
|
|
|
| 查询 | Request(请求) |
|---|---|
| 软件包中的捆绑包 |
|
|
|