×

了解 Operator Lifecycle Manager (OLM) 中系统的状态对于做出有关已安装 Operator 的决策以及调试其问题非常重要。OLM 提供了有关订阅及其相关目录源的状态和执行的操作的洞察。这有助于用户更好地了解其 Operator 的健康状况。

操作员订阅条件类型

订阅可以报告以下条件类型

表 1. 订阅条件类型
条件 描述

CatalogSourcesUnhealthy

一些或所有将在解析中使用的目录源都不健康。

InstallPlanMissing

缺少订阅的安装计划。

InstallPlanPending

订阅的安装计划正在等待安装。

InstallPlanFailed

订阅的安装计划已失败。

ResolutionFailed

订阅的依赖项解析已失败。

默认的 Red Hat OpenShift Service on AWS 集群 Operator 由集群版本 Operator (CVO) 管理,它们没有Subscription对象。应用程序 Operator 由 Operator Lifecycle Manager (OLM) 管理,它们具有Subscription对象。

其他资源

使用 CLI 查看操作员订阅状态

您可以使用 CLI 查看操作员订阅状态。

先决条件
  • 您可以作为具有dedicated-admin角色的用户访问集群。

  • 您已安装 OpenShift CLI (oc)。

步骤
  1. 列出 Operator 订阅

    $ oc get subs -n <operator_namespace>
  2. 使用oc describe命令检查Subscription资源

    $ oc describe sub <subscription_name> -n <operator_namespace>
  3. 在命令输出中,查找操作员订阅条件类型的状态的Conditions部分。在以下示例中,CatalogSourcesUnhealthy条件类型的状态为false,因为所有可用目录源均处于健康状态

    示例输出
    Name:         cluster-logging
    Namespace:    openshift-logging
    Labels:       operators.coreos.com/cluster-logging.openshift-logging=
    Annotations:  <none>
    API Version:  operators.coreos.com/v1alpha1
    Kind:         Subscription
    # ...
    Conditions:
       Last Transition Time:  2019-07-29T13:42:57Z
       Message:               all available catalogsources are healthy
       Reason:                AllCatalogSourcesHealthy
       Status:                False
       Type:                  CatalogSourcesUnhealthy
    # ...

默认的 Red Hat OpenShift Service on AWS 集群 Operator 由集群版本 Operator (CVO) 管理,它们没有Subscription对象。应用程序 Operator 由 Operator Lifecycle Manager (OLM) 管理,它们具有Subscription对象。

使用 CLI 查看操作员目录源状态

您可以使用 CLI 查看操作员目录源的状态。

先决条件
  • 您可以作为具有dedicated-admin角色的用户访问集群。

  • 您已安装 OpenShift CLI (oc)。

步骤
  1. 列出命名空间中的目录源。例如,您可以检查openshift-marketplace命名空间,该命名空间用于集群范围的目录源

    $ oc get catalogsources -n openshift-marketplace
    示例输出
    NAME                  DISPLAY               TYPE   PUBLISHER   AGE
    certified-operators   Certified Operators   grpc   Red Hat     55m
    community-operators   Community Operators   grpc   Red Hat     55m
    example-catalog       Example Catalog       grpc   Example Org 2m25s
    redhat-marketplace    Red Hat Marketplace   grpc   Red Hat     55m
    redhat-operators      Red Hat Operators     grpc   Red Hat     55m
  2. 使用oc describe命令获取有关目录源的更多详细信息和状态

    $ oc describe catalogsource example-catalog -n openshift-marketplace
    示例输出
    Name:         example-catalog
    Namespace:    openshift-marketplace
    Labels:       <none>
    Annotations:  operatorframework.io/managed-by: marketplace-operator
                  target.workload.openshift.io/management: {"effect": "PreferredDuringScheduling"}
    API Version:  operators.coreos.com/v1alpha1
    Kind:         CatalogSource
    # ...
    Status:
      Connection State:
        Address:              example-catalog.openshift-marketplace.svc:50051
        Last Connect:         2021-09-09T17:07:35Z
        Last Observed State:  TRANSIENT_FAILURE
      Registry Service:
        Created At:         2021-09-09T17:05:45Z
        Port:               50051
        Protocol:           grpc
        Service Name:       example-catalog
        Service Namespace:  openshift-marketplace
    # ...

    在前面的示例输出中,最后观察到的状态为TRANSIENT_FAILURE。此状态表示在为目录源建立连接时存在问题。

  3. 列出创建目录源的命名空间中的 Pod

    $ oc get pods -n openshift-marketplace
    示例输出
    NAME                                    READY   STATUS             RESTARTS   AGE
    certified-operators-cv9nn               1/1     Running            0          36m
    community-operators-6v8lp               1/1     Running            0          36m
    marketplace-operator-86bfc75f9b-jkgbc   1/1     Running            0          42m
    example-catalog-bwt8z                   0/1     ImagePullBackOff   0          3m55s
    redhat-marketplace-57p8c                1/1     Running            0          36m
    redhat-operators-smxx8                  1/1     Running            0          36m

    在命名空间中创建目录源时,会在该命名空间中为目录源创建一个 Pod。在前面的示例输出中,example-catalog-bwt8z Pod 的状态为ImagePullBackOff。此状态表示拉取目录源的索引映像时存在问题。

  4. 使用oc describe命令检查 Pod 以获取更详细的信息

    $ oc describe pod example-catalog-bwt8z -n openshift-marketplace
    示例输出
    Name:         example-catalog-bwt8z
    Namespace:    openshift-marketplace
    Priority:     0
    Node:         ci-ln-jyryyg2-f76d1-ggdbq-worker-b-vsxjd/10.0.128.2
    ...
    Events:
      Type     Reason          Age                From               Message
      ----     ------          ----               ----               -------
      Normal   Scheduled       48s                default-scheduler  Successfully assigned openshift-marketplace/example-catalog-bwt8z to ci-ln-jyryyf2-f76d1-fgdbq-worker-b-vsxjd
      Normal   AddedInterface  47s                multus             Add eth0 [10.131.0.40/23] from openshift-sdn
      Normal   BackOff         20s (x2 over 46s)  kubelet            Back-off pulling image "quay.io/example-org/example-catalog:v1"
      Warning  Failed          20s (x2 over 46s)  kubelet            Error: ImagePullBackOff
      Normal   Pulling         8s (x3 over 47s)   kubelet            Pulling image "quay.io/example-org/example-catalog:v1"
      Warning  Failed          8s (x3 over 47s)   kubelet            Failed to pull image "quay.io/example-org/example-catalog:v1": rpc error: code = Unknown desc = reading manifest v1 in quay.io/example-org/example-catalog: unauthorized: access to the requested resource is not authorized
      Warning  Failed          8s (x3 over 47s)   kubelet            Error: ErrImagePull

    在前面的示例输出中,错误消息表明目录源的索引映像由于授权问题而无法成功拉取。例如,索引映像可能存储在需要登录凭据的注册表中。