×

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

操作符订阅条件类型

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

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

CatalogSourcesUnhealthy

一些或所有要用于解析的目录源都不健康。

InstallPlanMissing

缺少订阅的安装计划。

InstallPlanPending

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

InstallPlanFailed

订阅的安装计划已失败。

ResolutionFailed

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

默认的 OpenShift Container Platform 集群操作符由集群版本操作符 (CVO) 管理,它们没有Subscription 对象。应用程序操作符由操作符生命周期管理器 (OLM) 管理,它们有Subscription 对象。

其他资源

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

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

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

  • 您已安装 OpenShift CLI (oc)。

步骤
  1. 列出操作符订阅

    $ 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
    # ...

默认的 OpenShift Container Platform 集群操作符由集群版本操作符 (CVO) 管理,它们没有Subscription 对象。应用程序操作符由操作符生命周期管理器 (OLM) 管理,它们有Subscription 对象。

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

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

先决条件
  • 您可以作为具有cluster-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

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