$ oc get subs -n <operator_namespace>
如果遇到操作符问题,请验证操作符订阅状态。检查集群中操作符Pod的运行状况并收集操作符日志以进行诊断。
订阅可以报告以下条件类型
条件 | 描述 |
---|---|
|
部分或所有用于解析的目录源都不健康。 |
|
缺少订阅的安装计划。 |
|
订阅的安装计划正在等待安装。 |
|
订阅的安装计划已失败。 |
|
订阅的依赖项解析已失败。 |
AWS集群上的默认Red Hat OpenShift Service操作符由集群版本操作符(CVO)管理,它们没有 |
您可以使用CLI查看操作符订阅状态。
您可以作为具有dedicated-admin
角色的用户访问集群。
您已安装OpenShift CLI (oc
)。
列出操作符订阅
$ oc get subs -n <operator_namespace>
使用oc describe
命令检查Subscription
资源
$ oc describe sub <subscription_name> -n <operator_namespace>
在命令输出中,查找操作符订阅条件类型的状态的“条件”部分。在下面的示例中,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
# ...
AWS集群上的默认Red Hat OpenShift Service操作符由集群版本操作符(CVO)管理,它们没有 |
您可以使用CLI查看操作符目录源的状态。
您可以作为具有dedicated-admin
角色的用户访问集群。
您已安装OpenShift CLI (oc
)。
列出命名空间中的目录源。例如,您可以检查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
使用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
。此状态表示在为目录源建立连接时存在问题。
列出创建目录源的命名空间中的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
。此状态表示拉取目录源的索引映像时存在问题。
使用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
在上一个示例输出中,错误消息表明目录源的索引映像由于授权问题而无法成功拉取。例如,索引映像可能存储在需要登录凭据的注册表中。
gRPC文档:连接状态
您可以列出集群中的操作符Pod及其状态。您还可以收集详细的操作符Pod摘要。
您可以作为具有dedicated-admin
角色的用户访问集群。
您的API服务仍在运行。
您已安装OpenShift CLI (oc
)。
列出集群中运行的操作符。输出包括操作符版本、可用性和运行时间信息
$ oc get clusteroperators
列出在操作符命名空间中运行的操作符Pod,以及Pod状态、重启次数和运行时间
$ oc get pod -n <operator_namespace>
输出详细的操作符Pod摘要
$ oc describe pod <operator_pod_name> -n <operator_namespace>
如果遇到操作符问题,您可以从操作符Pod日志中收集详细的诊断信息。
您可以作为具有dedicated-admin
角色的用户访问集群。
您的API服务仍在运行。
您已安装OpenShift CLI (oc
)。
您拥有控制平面或控制平面机器的完全限定域名。
列出在操作符命名空间中运行的操作符Pod,以及Pod状态、重启次数和运行时间
$ oc get pods -n <operator_namespace>
查看操作符Pod的日志
$ oc logs pod/<pod_name> -n <operator_namespace>
如果操作符Pod有多个容器,则上述命令将产生一个错误,其中包含每个容器的名称。查询单个容器的日志
$ oc logs pod/<operator_pod_name> -c <container_name> -n <operator_namespace>
如果API无法运行,请改用SSH在每个控制平面节点上查看操作符Pod和容器日志。将<master-node>.<cluster_name>.<base_domain>
替换为适当的值。
列出每个控制平面节点上的Pod
$ ssh core@<master-node>.<cluster_name>.<base_domain> sudo crictl pods
对于任何未显示Ready
状态的操作符Pod,请详细检查Pod的状态。将<operator_pod_id>
替换为上述命令输出中列出的操作符Pod的ID
$ ssh core@<master-node>.<cluster_name>.<base_domain> sudo crictl inspectp <operator_pod_id>
列出与操作符Pod相关的容器
$ ssh core@<master-node>.<cluster_name>.<base_domain> sudo crictl ps --pod=<operator_pod_id>
对于任何未显示Ready
状态的操作符容器,请详细检查容器的状态。将<container_id>
替换为上述命令输出中列出的容器ID
$ ssh core@<master-node>.<cluster_name>.<base_domain> sudo crictl inspect <container_id>
查看任何未显示Ready
状态的操作符容器的日志。将<container_id>
替换为上述命令输出中列出的容器ID
$ ssh core@<master-node>.<cluster_name>.<base_domain> sudo crictl logs -f <container_id>
运行Red Hat Enterprise Linux CoreOS (RHCOS)的AWS集群节点上的Red Hat OpenShift Service是不可变的,并依赖于操作符来应用集群更改。不建议使用SSH访问集群节点。在尝试通过SSH收集诊断数据之前,请先查看是否可以通过运行 |