×

Operator Lifecycle Manager (OLM) v1 仅为技术预览功能。技术预览功能不受 Red Hat 生产服务等级协议 (SLA) 的支持,并且功能可能不完整。Red Hat 不建议在生产环境中使用它们。这些功能可让客户提前访问即将推出的产品功能,从而能够在开发过程中测试功能并提供反馈。

有关 Red Hat 技术预览功能的支持范围的更多信息,请参阅 技术预览功能支持范围

将目录添加到集群后,您可以访问发布到该目录的扩展和 Operators 的版本、补丁和无线更新。

您可以使用自定义资源 (CR) 通过 CLI 以声明方式管理扩展。

目前,Operator Lifecycle Manager (OLM) v1 无法验证私有注册表(例如 Red Hat 提供的 Operator 目录)。这是一个已知问题。因此,依赖于安装 Red Hat Operators 目录的 OLM v1 过程不起作用。(OCPBUGS-36364

支持的扩展

目前,Operator Lifecycle Manager (OLM) v1 支持安装满足以下所有条件的集群扩展

  • 扩展必须使用现有 OLM 中引入的registry+v1 bundle 格式。

  • 扩展必须支持通过AllNamespaces安装模式进行安装。

  • 扩展不能使用 Webhook。

  • 扩展不能使用以下任何基于文件的目录属性声明依赖项

    • olm.gvk.required

    • olm.package.required

    • olm.constraint

OLM v1 检查您要安装的扩展是否满足这些约束。如果要安装的扩展不满足这些约束,则会在集群扩展的条件中打印错误消息。

Operator Lifecycle Manager (OLM) v1 不支持现有 OLM 中引入的OperatorConditions API。

如果扩展仅依赖OperatorConditions API 来管理更新,则扩展可能无法正确安装。大多数依赖此 API 的扩展会在启动时失败,但有些可能会在协调过程中失败。

作为解决方法,您可以将扩展固定到特定版本。当您想要更新扩展时,请查阅扩展的文档以了解何时可以安全地将扩展固定到新版本。

其他资源

查找要从目录安装的 Operators

将目录添加到集群后,您可以查询目录以查找要安装的 Operators 和扩展。在查询目录之前,必须将目录服务器服务端口转发。

先决条件
  • 您已将目录添加到集群。

  • 您已安装jq CLI 工具。

步骤
  1. 通过运行以下命令,将openshift-catalogd命名空间中的目录服务器服务端口转发

    $ oc -n openshift-catalogd port-forward svc/catalogd-catalogserver 8080:443
  2. 在新终端窗口或选项卡中,通过运行以下命令在本地下载目录的 JSON 文件

    $ curl -L -k https://127.0.0.1:8080/catalogs/<catalog_name>/all.json \
      -C - -o /<path>/<catalog_name>.json
    示例命令
    $ curl -L -k https://127.0.0.1:8080/catalogs/redhat-operators/all.json \
      -C - -o /home/username/catalogs/rhoc.json
  3. 运行以下命令之一以返回目录中的 Operators 和扩展列表。

    目前,Operator Lifecycle Manager (OLM) v1 支持安装满足以下所有条件的集群扩展

    • 扩展必须使用现有 OLM 中引入的registry+v1 bundle 格式。

    • 扩展必须支持通过AllNamespaces安装模式进行安装。

    • 扩展不能使用 Webhook。

    • 扩展不能使用以下任何基于文件的目录属性声明依赖项

      • olm.gvk.required

      • olm.package.required

      • olm.constraint

    OLM v1 检查您要安装的扩展是否满足这些约束。如果要安装的扩展不满足这些约束,则会在集群扩展的条件中打印错误消息。

    • 通过运行以下命令,获取本地目录文件中所有 Operators 和扩展的列表

      $ jq -s '.[] | select(.schema == "olm.package") | .name' \
        /<path>/<filename>.json
      示例命令
      $ jq -s '.[] | select(.schema == "olm.package") | .name' \
        /home/username/catalogs/rhoc.json
      示例输出
      NAME                                                        AGE
      "3scale-operator"
      "advanced-cluster-management"
      "amq-broker-rhel8"
      "amq-online"
      "amq-streams"
      "amq7-interconnect-operator"
      "ansible-automation-platform-operator"
      "ansible-cloud-addons-operator"
      "apicast-operator"
      "aws-efs-csi-driver-operator"
      "aws-load-balancer-operator"
      "bamoe-businessautomation-operator"
      "bamoe-kogito-operator"
      "bare-metal-event-relay"
      "businessautomation-operator"
      ...
    • 通过运行以下命令,获取支持AllNamespaces安装模式且不使用 Webhook 的软件包列表

      $ 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}' \
        /<path>/<catalog_name>.json
      示例输出
      {"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"}
      ...
  4. 通过运行以下命令,检查 Operator 或扩展元数据的內容

    $ jq -s '.[] | select( .schema == "olm.package") | \
      select( .name == "<package_name>")' /<path>/<catalog_name>.json
    示例命令
    $ jq -s '.[] | select( .schema == "olm.package") | \
      select( .name == "openshift-pipelines-operator-rh")' \
      /home/username/rhoc.json
    示例输出
    {
      "defaultChannel": "stable",
      "icon": {
        "base64data": "PHN2ZyB4bWxu..."
        "mediatype": "image/png"
      },
      "name": "openshift-pipelines-operator-rh",
      "schema": "olm.package"
    }

常见的目录查询

您可以使用jq CLI 工具查询目录。

表 1. 常见的软件包查询
查询 请求

目录中的可用软件包

$ jq -s '.[] | select( .schema == "olm.package") | \
  .name' <catalog_name>.json

支持AllNamespaces安装模式且不使用 Webhook 的软件包

$ 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}' \
  <catalog_name>.json

软件包元数据

$ jq -s '.[] | select( .schema == "olm.package") | \
  select( .name == "<package_name>")' <catalog_name>.json

软件包中的目录 Blob

$ jq -s '.[] | select( .package == "<package_name>")' \
  <catalog_name>.json
表 2. 常见的通道查询
查询 请求

软件包中的通道

$ jq -s '.[] | select( .schema == "olm.channel" ) | \
  select( .package == "<package_name>") | .name' \
  <catalog_name>.json

通道中的版本

$ jq -s '.[] | select( .package == "<package_name>" ) | \
  select( .schema == "olm.channel" ) | \
  select( .name == "<channel_name>" ) | \
  .entries | .[] | .name' <catalog_name>.json
  • 通道中的最新版本

  • 升级路径

$ jq -s '.[] | select( .schema == "olm.channel" ) | \
  select ( .name == "<channel>") | \
  select( .package == "<package_name>")' \
  <catalog_name>.json
表 3. 常见的 bundle 查询
查询 请求

软件包中的 bundle

$ jq -s '.[] | select( .schema == "olm.bundle" ) | \
  select( .package == "<package_name>") | .name' \
  <catalog_name>.json
  • bundle 依赖项

  • 可用 API

$ jq -s '.[] | select( .schema == "olm.bundle" ) | \
  select ( .name == "<bundle_name>") | \
  select( .package == "<package_name>")' \
  <catalog_name>.json

创建服务帐户以管理集群扩展

与现有的 Operator Lifecycle Manager (OLM) 不同,OLM v1 没有安装、更新和管理集群扩展的权限。集群管理员必须创建一个服务帐户并分配安装、更新和管理集群扩展所需的基于角色的访问控制 (RBAC)。

OLM v1 中存在一个已知问题。如果您没有为扩展的服务帐户分配正确的基于角色的访问控制 (RBAC),OLM v1 将卡住并且协调将停止。

目前,OLM v1 还没有工具帮助扩展管理员找到服务帐户的正确 RBAC。

由于 OLM v1 是技术预览功能,不能用于生产集群,您可以通过使用文档中包含的更宽松的 RBAC 来避免此问题。

此 RBAC 仅用于测试目的。请勿在生产集群中使用它。

先决条件
  • 使用具有 `cluster-admin` 权限的帐户访问 OpenShift Container Platform 集群。

步骤
  1. 创建服务帐户,类似于以下示例

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: <extension>-installer
      namespace: <namespace>
    示例 `extension-service-account.yaml` 文件
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: pipelines-installer
      namespace: pipelines
  2. 运行以下命令应用服务帐户

    $ oc apply -f extension-service-account.yaml
  3. 创建集群角色并分配 RBAC,类似于以下示例

    以下集群角色不遵循最小权限原则。此集群角色仅用于测试目的。请勿在生产集群中使用它。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: <extension>-installer-clusterrole
    rules:
    - apiGroups: ["*"]
      resources: ["*"]
      verbs: ["*"]
    示例 `pipelines-cluster-role.yaml` 文件
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: pipelines-installer-clusterrole
    rules:
    - apiGroups: ["*"]
      resources: ["*"]
      verbs: ["*"]
  4. 运行以下命令将集群角色添加到集群

    $ oc apply -f pipelines-role.yaml
  5. 通过创建集群角色绑定来将集群角色授予的权限绑定到服务帐户,类似于以下示例

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: <extension>-installer-binding
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: <extension>-installer-clusterrole
    subjects:
    - kind: ServiceAccount
      name: <extension>-installer
      namespace: <namespace>
    示例 `pipelines-cluster-role-binding.yaml` 文件
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: pipelines-installer-binding
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: pipelines-installer-clusterrole
    subjects:
    - kind: ServiceAccount
      name: pipelines-installer
      namespace: pipelines
  6. 运行以下命令应用集群角色绑定

    $ oc apply -f pipelines-cluster-role-binding.yaml

从目录安装集群扩展

您可以通过创建自定义资源 (CR) 并将其应用于集群来从目录安装扩展。Operator Lifecycle Manager (OLM) v1 支持安装集群范围的集群扩展,包括通过 `registry+v1` bundle 格式的现有 OLM Operators。更多信息,请参见 *支持的扩展*。

目前,Operator Lifecycle Manager (OLM) v1 无法验证私有注册表(例如 Red Hat 提供的 Operator 目录)。这是一个已知问题。因此,依赖于安装 Red Hat Operators 目录的 OLM v1 过程不起作用。(OCPBUGS-36364

先决条件
  • 您已将目录添加到集群。

  • 您已下载目录文件的本地副本。

  • 您已安装jq CLI 工具。

  • 您已创建服务帐户并分配了足够的基于角色的访问控制 (RBAC) 来安装、更新和管理您要安装的扩展。更多信息,请参见 *创建服务帐户*。

步骤
  1. 通过完成以下步骤,检查目录文件的本地副本中的包的通道和版本信息

    1. 运行以下命令获取所选包的通道列表

      $ jq -s '.[] | select( .schema == "olm.channel" ) | \
        select( .package == "<package_name>") | \
        .name' /<path>/<catalog_name>.json
      示例命令
      $ jq -s '.[] | select( .schema == "olm.channel" ) | \
        select( .package == "openshift-pipelines-operator-rh") | \
        .name' /home/username/rhoc.json
      示例输出
      "latest"
      "pipelines-1.11"
      "pipelines-1.12"
      "pipelines-1.13"
      "pipelines-1.14"
    2. 运行以下命令获取通道中发布的版本的列表

      $ jq -s '.[] | select( .package == "<package_name>" ) | \
        select( .schema == "olm.channel" ) | \
        select( .name == "<channel_name>" ) | .entries | \
        .[] | .name' /<path>/<catalog_name>.json
      示例命令
      $ jq -s '.[] | select( .package == "openshift-pipelines-operator-rh" ) | \
      select( .schema == "olm.channel" ) | select( .name == "latest" ) | \
      .entries | .[] | .name' /home/username/rhoc.json
      示例输出
      "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"
  2. 如果要将扩展安装到新的命名空间,请运行以下命令

    $ oc adm new-project <new_namespace>
  3. 创建 CR,类似于以下示例

    示例 `pipelines-operator.yaml` CR
    apiVersion: olm.operatorframework.io/v1alpha1
    kind: ClusterExtension
    metadata:
      name: pipelines-operator
    spec:
      packageName: openshift-pipelines-operator-rh
      installNamespace: <namespace>
      serviceAccount:
        name: <service_account>
      channel: <channel>
      version: "<version>"

    其中

    <namespace>

    指定要安装 bundle 的命名空间,例如 `pipelines` 或 `my-extension`。扩展仍然是集群范围的,可能包含安装在不同命名空间中的资源。

    <service_account>

    指定您创建的服务帐户的名称,用于安装、更新和管理您的扩展。

    <channel>

    可选:指定要安装或更新的包的通道,例如 `pipelines-1.11` 或 `latest`。

    <version>

    可选:指定要安装或更新的包的版本或版本范围,例如 `1.11.1`、`1.12.x` 或 `>=1.12.1`。更多信息,请参见“指定目标版本的示例自定义资源 (CR)”和“版本范围支持”。

    如果您尝试安装名称不唯一的 Operator 或扩展,则安装可能会失败或导致不可预测的结果。出现这种情况的原因如下:

    • 如果在集群上安装了多个目录,则 Operator Lifecycle Manager (OLM) v1 不包含在安装 Operator 或扩展时指定目录的机制。

    • OLM v1 要求所有可在集群上安装的 Operator 和扩展都为其 bundle 和包使用唯一的名称。

  4. 运行以下命令将 CR 应用于集群

    $ oc apply -f pipeline-operator.yaml
    示例输出
    clusterextension.olm.operatorframework.io/pipelines-operator created
验证
  1. 运行以下命令以 YAML 格式查看 Operator 或扩展的 CR

    $ oc get clusterextension pipelines-operator -o yaml
    示例输出
    apiVersion: v1
    items:
    - apiVersion: olm.operatorframework.io/v1alpha1
      kind: ClusterExtension
      metadata:
        annotations:
          kubectl.kubernetes.io/last-applied-configuration: |
            {"apiVersion":"olm.operatorframework.io/v1alpha1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipelines-operator"},"spec":{"channel":"latest","installNamespace":"pipelines","packageName":"openshift-pipelines-operator-rh","serviceAccount":{"name":"pipelines-installer"},"pollInterval":"30m"}}
        creationTimestamp: "2024-06-10T17:50:51Z"
        finalizers:
        - olm.operatorframework.io/cleanup-unpack-cache
        generation: 1
        name: pipelines-operator
        resourceVersion: "53324"
        uid: c54237be-cde4-46d4-9b31-d0ec6acc19bf
      spec:
        channel: latest
        installNamespace: pipelines
        packageName: openshift-pipelines-operator-rh
        serviceAccount:
          name: pipelines-installer
        upgradeConstraintPolicy: Enforce
      status:
        conditions:
        - lastTransitionTime: "2024-06-10T17:50:58Z"
          message: resolved to "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:dd3d18367da2be42539e5dde8e484dac3df33ba3ce1d5bcf896838954f3864ec"
          observedGeneration: 1
          reason: Success
          status: "True"
          type: Resolved
        - lastTransitionTime: "2024-06-10T17:51:11Z"
          message: installed from "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:dd3d18367da2be42539e5dde8e484dac3df33ba3ce1d5bcf896838954f3864ec"
          observedGeneration: 1
          reason: Success
          status: "True"
          type: Installed
        - lastTransitionTime: "2024-06-10T17:50:58Z"
          message: ""
          observedGeneration: 1
          reason: Deprecated
          status: "False"
          type: Deprecated
        - lastTransitionTime: "2024-06-10T17:50:58Z"
          message: ""
          observedGeneration: 1
          reason: Deprecated
          status: "False"
          type: PackageDeprecated
        - lastTransitionTime: "2024-06-10T17:50:58Z"
          message: ""
          observedGeneration: 1
          reason: Deprecated
          status: "False"
          type: ChannelDeprecated
        - lastTransitionTime: "2024-06-10T17:50:58Z"
          message: ""
          observedGeneration: 1
          reason: Deprecated
          status: "False"
          type: BundleDeprecated
        - lastTransitionTime: "2024-06-10T17:50:58Z"
          message: 'unpack successful:
          observedGeneration: 1
          reason: UnpackSuccess
          status: "True"
          type: Unpacked
        installedBundle:
          name: openshift-pipelines-operator-rh.v1.14.4
          version: 1.14.4
        resolvedBundle:
          name: openshift-pipelines-operator-rh.v1.14.4
          version: 1.14.4

    其中

    spec.channel

    显示扩展的 CR 中定义的通道。

    spec.version

    显示扩展的 CR 中定义的版本或版本范围。

    status.conditions

    显示有关扩展的状态和运行状况的信息。

    type: Deprecated

    显示以下一项或多项是否已弃用

    type: PackageDeprecated

    显示解析的包是否已弃用。

    type: ChannelDeprecated

    显示解析的通道是否已弃用。

    type: BundleDeprecated

    显示解析的 bundle 是否已弃用。

    `status` 字段中的 `False` 值表示 `reason: Deprecated` 条件未弃用。 `status` 字段中的 `True` 值表示 `reason: Deprecated` 条件已弃用。

    installedBundle.name

    显示已安装 bundle 的名称。

    installedBundle.version

    显示已安装 bundle 的版本。

    resolvedBundle.name

    显示解析的 bundle 的名称。

    resolvedBundle.version

    显示解析的 bundle 的版本。

更新集群扩展

您可以通过手动编辑自定义资源 (CR) 并应用更改来更新您的集群扩展或 Operator。

先决条件
  • 您已安装目录。

  • 您已下载目录文件的本地副本。

  • 您已安装 Operator 或扩展。

  • 您已安装jq CLI 工具。

步骤
  1. 通过完成以下步骤,检查目录文件的本地副本中的包的通道和版本信息

    1. 运行以下命令获取所选包的通道列表

      $ jq -s '.[] | select( .schema == "olm.channel" ) | \
        select( .package == "<package_name>") | \
        .name' /<path>/<catalog_name>.json
      示例命令
      $ jq -s '.[] | select( .schema == "olm.channel" ) | \
        select( .package == "openshift-pipelines-operator-rh") | \
        .name' /home/username/rhoc.json
      示例输出
      "latest"
      "pipelines-1.11"
      "pipelines-1.12"
      "pipelines-1.13"
      "pipelines-1.14"
    2. 运行以下命令获取通道中发布的版本的列表

      $ jq -s '.[] | select( .package == "<package_name>" ) | \
        select( .schema == "olm.channel" ) | \
        select( .name == "<channel_name>" ) | .entries | \
        .[] | .name' /<path>/<catalog_name>.json
      示例命令
      $ jq -s '.[] | select( .package == "openshift-pipelines-operator-rh" ) | \
      select( .schema == "olm.channel" ) | select( .name == "latest" ) | \
      .entries | .[] | .name' /home/username/rhoc.json
      示例输出
      "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"
  2. 运行以下命令找出 Operator 或扩展的 CR 中指定的版本或通道

    $ oc get clusterextension <operator_name> -o yaml
    示例命令
    $ oc get clusterextension pipelines-operator -o yaml
    示例输出
    apiVersion: olm.operatorframework.io/v1alpha1
    kind: ClusterExtension
    metadata:
      annotations:
        kubectl.kubernetes.io/last-applied-configuration: |
          {"apiVersion":"olm.operatorframework.io/v1alpha1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipelines-operator"},"spec":{"channel":"latest","installNamespace":"openshift-operators","packageName":"openshift-pipelines-operator-rh","pollInterval":"30m","version":"\u003c1.12"}}
      creationTimestamp: "2024-06-11T15:55:37Z"
      generation: 1
      name: pipelines-operator
      resourceVersion: "69776"
      uid: 6a11dff3-bfa3-42b8-9e5f-d8babbd6486f
    spec:
      channel: latest
      installNamespace: openshift-operators
      packageName: openshift-pipelines-operator-rh
      upgradeConstraintPolicy: Enforce
      version: <1.12
    status:
      conditions:
      - lastTransitionTime: "2024-06-11T15:56:09Z"
        message: installed from "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:e09d37bb1e754db42324fd18c1cb3e7ce77e7b7fcbf4932d0535391579938280"
        observedGeneration: 1
        reason: Success
        status: "True"
        type: Installed
      - lastTransitionTime: "2024-06-11T15:55:50Z"
        message: resolved to "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:e09d37bb1e754db42324fd18c1cb3e7ce77e7b7fcbf4932d0535391579938280"
        observedGeneration: 1
        reason: Success
        status: "True"
        type: Resolved
      - lastTransitionTime: "2024-06-11T15:55:50Z"
        message: ""
        observedGeneration: 1
        reason: Deprecated
        status: "False"
        type: Deprecated
      - lastTransitionTime: "2024-06-11T15:55:50Z"
        message: ""
        observedGeneration: 1
        reason: Deprecated
        status: "False"
        type: PackageDeprecated
      - lastTransitionTime: "2024-06-11T15:55:50Z"
        message: ""
        observedGeneration: 1
        reason: Deprecated
        status: "False"
        type: ChannelDeprecated
      - lastTransitionTime: "2024-06-11T15:55:50Z"
        message: ""
        observedGeneration: 1
        reason: Deprecated
        status: "False"
        type: BundleDeprecated
      installedBundle:
        name: openshift-pipelines-operator-rh.v1.11.1
        version: 1.11.1
      resolvedBundle:
        name: openshift-pipelines-operator-rh.v1.11.1
        version: 1.11.1
  3. 使用以下方法之一编辑您的 CR

    • 如果要将 Operator 或扩展固定到特定版本(例如 `1.12.1`),请类似于以下示例编辑您的 CR

      示例 `pipelines-operator.yaml` CR
      apiVersion: olm.operatorframework.io/v1alpha1
      kind: ClusterExtension
      metadata:
        name: pipelines-operator
      spec:
        packageName: openshift-pipelines-operator-rh
        installNamespace: <namespace>
        version: "1.12.1" (1)
      1 将版本从 `1.11.1` 更新到 `1.12.1`
    • 如果要定义一系列可接受的更新版本,请类似于以下示例编辑您的 CR

      指定版本范围的示例 CR
      apiVersion: olm.operatorframework.io/v1alpha1
      kind: ClusterExtension
      metadata:
        name: pipelines-operator
      spec:
        packageName: openshift-pipelines-operator-rh
        installNamespace: <namespace>
        version: ">1.11.1, <1.13" (1)
      1 指定所需的版本范围大于版本 `1.11.1` 且小于 `1.13`。更多信息,请参见“版本范围支持”和“版本比较字符串”。
    • 如果要更新到可以从通道解析的最新版本,请类似于以下示例编辑您的 CR

      指定通道的示例 CR
      apiVersion: olm.operatorframework.io/v1alpha1
      kind: ClusterExtension
      metadata:
        name: pipelines-operator
      spec:
        packageName: openshift-pipelines-operator-rh
        installNamespace: <namespace>
        channel: pipelines-1.13 (1)
      1 安装可以从指定通道解析的最新版本。通道的更新会自动安装。
    • 如果要指定通道和版本或版本范围,请类似于以下示例编辑您的 CR

      指定通道和版本范围的示例 CR
      apiVersion: olm.operatorframework.io/v1alpha1
      kind: ClusterExtension
      metadata:
        name: pipelines-operator
      spec:
        packageName: openshift-pipelines-operator-rh
        installNamespace: <namespace>
        channel: latest
        version: "<1.13"

      更多信息,请参见“指定目标版本的示例自定义资源 (CR)”。

  4. 运行以下命令将更新应用于集群

    $ oc apply -f pipelines-operator.yaml
    示例输出
    clusterextension.olm.operatorframework.io/pipelines-operator configured

    您可以通过运行以下命令从 CLI 修补并应用对 CR 的更改

    $ oc patch clusterextension/pipelines-operator -p \
      '{"spec":{"version":"<1.13"}}' \
      --type=merge
    示例输出
    clusterextension.olm.operatorframework.io/pipelines-operator patched
验证
  • 运行以下命令验证通道和版本更新是否已应用

    $ oc get clusterextension pipelines-operator -o yaml
    示例输出
    apiVersion: olm.operatorframework.io/v1alpha1
    kind: ClusterExtension
    metadata:
      annotations:
        kubectl.kubernetes.io/last-applied-configuration: |
          {"apiVersion":"olm.operatorframework.io/v1alpha1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipelines-operator"},"spec":{"channel":"latest","installNamespace":"openshift-operators","packageName":"openshift-pipelines-operator-rh","pollInterval":"30m","version":"\u003c1.13"}}
      creationTimestamp: "2024-06-11T18:23:26Z"
      generation: 2
      name: pipelines-operator
      resourceVersion: "66310"
      uid: ce0416ba-13ea-4069-a6c8-e5efcbc47537
    spec:
      channel: latest
      installNamespace: openshift-operators
      packageName: openshift-pipelines-operator-rh
      upgradeConstraintPolicy: Enforce
      version: <1.13
    status:
      conditions:
      - lastTransitionTime: "2024-06-11T18:23:33Z"
        message: resolved to "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:814742c8a7cc7e2662598e114c35c13993a7b423cfe92548124e43ea5d469f82"
        observedGeneration: 2
        reason: Success
        status: "True"
        type: Resolved
      - lastTransitionTime: "2024-06-11T18:23:52Z"
        message: installed from "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:814742c8a7cc7e2662598e114c35c13993a7b423cfe92548124e43ea5d469f82"
        observedGeneration: 2
        reason: Success
        status: "True"
        type: Installed
      - lastTransitionTime: "2024-06-11T18:23:33Z"
        message: ""
        observedGeneration: 2
        reason: Deprecated
        status: "False"
        type: Deprecated
      - lastTransitionTime: "2024-06-11T18:23:33Z"
        message: ""
        observedGeneration: 2
        reason: Deprecated
        status: "False"
        type: PackageDeprecated
      - lastTransitionTime: "2024-06-11T18:23:33Z"
        message: ""
        observedGeneration: 2
        reason: Deprecated
        status: "False"
        type: ChannelDeprecated
      - lastTransitionTime: "2024-06-11T18:23:33Z"
        message: ""
        observedGeneration: 2
        reason: Deprecated
        status: "False"
        type: BundleDeprecated
      installedBundle:
        name: openshift-pipelines-operator-rh.v1.12.2
        version: 1.12.2
      resolvedBundle:
        name: openshift-pipelines-operator-rh.v1.12.2
        version: 1.12.2
故障排除
  • 如果指定的目标版本或通道已弃用或不存在,您可以运行以下命令检查扩展的状态

    $ oc get clusterextension <operator_name> -o yaml
    版本不存在的示例输出
    apiVersion: olm.operatorframework.io/v1alpha1
    kind: ClusterExtension
    metadata:
      annotations:
        kubectl.kubernetes.io/last-applied-configuration: |
          {"apiVersion":"olm.operatorframework.io/v1alpha1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipelines-operator"},"spec":{"channel":"latest","installNamespace":"openshift-operators","packageName":"openshift-pipelines-operator-rh","pollInterval":"30m","version":"3.0"}}
      creationTimestamp: "2024-06-11T18:23:26Z"
      generation: 3
      name: pipelines-operator
      resourceVersion: "71852"
      uid: ce0416ba-13ea-4069-a6c8-e5efcbc47537
    spec:
      channel: latest
      installNamespace: openshift-operators
      packageName: openshift-pipelines-operator-rh
      upgradeConstraintPolicy: Enforce
      version: "3.0"
    status:
      conditions:
      - lastTransitionTime: "2024-06-11T18:29:02Z"
        message: 'error upgrading from currently installed version "1.12.2": no package
          "openshift-pipelines-operator-rh" matching version "3.0" found in channel "latest"'
        observedGeneration: 3
        reason: ResolutionFailed
        status: "False"
        type: Resolved
      - lastTransitionTime: "2024-06-11T18:29:02Z"
        message: installation has not been attempted as resolution failed
        observedGeneration: 3
        reason: InstallationStatusUnknown
        status: Unknown
        type: Installed
      - lastTransitionTime: "2024-06-11T18:29:02Z"
        message: deprecation checks have not been attempted as resolution failed
        observedGeneration: 3
        reason: Deprecated
        status: Unknown
        type: Deprecated
      - lastTransitionTime: "2024-06-11T18:29:02Z"
        message: deprecation checks have not been attempted as resolution failed
        observedGeneration: 3
        reason: Deprecated
        status: Unknown
        type: PackageDeprecated
      - lastTransitionTime: "2024-06-11T18:29:02Z"
        message: deprecation checks have not been attempted as resolution failed
        observedGeneration: 3
        reason: Deprecated
        status: Unknown
        type: ChannelDeprecated
      - lastTransitionTime: "2024-06-11T18:29:02Z"
        message: deprecation checks have not been attempted as resolution failed
        observedGeneration: 3
        reason: Deprecated
        status: Unknown
        type: BundleDeprecated
其他资源

删除 Operator

您可以通过删除 `ClusterExtension` 自定义资源 (CR) 来删除 Operator 及其自定义资源定义 (CRD)。

先决条件
  • 您已安装目录。

  • 您已安装 Operator。

步骤
  • 运行以下命令删除 Operator 及其 CRD

    $ oc delete clusterextension <operator_name>
    示例输出
    clusterextension.olm.operatorframework.io "<operator_name>" deleted
验证
  • 运行以下命令以验证您的 Operator 及其资源是否已删除

    • 运行以下命令验证 Operator 是否已删除

      $ oc get clusterextensions
      示例输出
      No resources found
    • 运行以下命令验证 Operator 的系统命名空间是否已删除

      $ oc get ns <operator_name>-system
      示例输出
      Error from server (NotFound): namespaces "<operator_name>-system" not found