3.2. OperatorHub 架构

OperatorHub UI 组件默认由 openshift-marketplace 命名空间中 OpenShift Container Platform 上的 Marketplace Operator 驱动。

Marketplace Operator 负责管理 OperatorHub 和 OperatorSource 自定义资源定义 (CRD)。

注意

尽管某些 OperatorSource 信息会通过 OperatorHub 用户界面公开,但只有创建自有 Operator 的用户可直接使用这些信息。

注意

虽然 OperatorHub 不再使用 CatalogSourceConfig 资源,但在 OpenShift Container Platform 中仍支持这些资源。

3.2.1. OperatorHub CRD

您可使用 OperatorHub CRD,将集群上 OperatorHub 提供的默认 OperatorSource 的状态更改为启用或禁用。该功能对于在有限网络环境中配置 OpenShift Container Platform 来说非常实用。

OperatorHub 自定义资源示例

apiVersion: config.openshift.io/v1
kind: OperatorHub
metadata:
  name: cluster
spec:
  disableAllDefaultSources: true 1
  sources: [ 2
    {
      name: "community-operators",
      disabled: false
    }
  ]

1
disableAllDefaultSources 是一种覆盖机制,用于控制在 OpenShift Container Platform 安装期间默认配置的所有默认 OperatorSource 的可用性。
2
通过更改每个源的 disabled 参数值,即可分别禁用各个默认 OperatorSource。

3.2.2. OperatorSource CRD

对于各个 Operator,OperatorSource CRD 用于定义用于存储 Operator 包的外部数据存储。

OperatorSource 自定义资源示例

apiVersion: operators.coreos.com/v1
kind: OperatorSource
metadata:
  name: community-operators
  namespace: marketplace
spec:
  type: appregistry 1
  endpoint: https://quay.io/cnr 2
  registryNamespace: community-operators 3
  displayName: "Community Operators" 4
  publisher: "Red Hat" 5

1
要将数据存储标识为应用程序 registry,请将 type 设置为 appregistry
2
目前,Quay 是 OperatorHub 使用的外部数据存储,因此 Quay.io appregistry 的端点被设置为 https://quay.io/cnr
3
对于社区 Operator,registryNamespace 会被设置为 community-operator
4
可选择将 displayName 设置为 OperatorHub UI 中显示的 Operator 的名称。
5
也可选择将 publisher 设置为 OperatorHub UI 中显示的发布该 Operator 的个人或机构。