28.3. 检查 Kafka 重启
使用 oc 命令列出 Cluster Operator 启动的重启事件。使用 reportingController 或 source 事件字段将 Cluster Operator 设置为报告组件来过滤 Cluster Operator 发出的重启事件。
先决条件
- Cluster Operator 在 OpenShift 集群中运行。
流程
获取 Cluster Operator 发出的所有重启事件:
oc -n kafka get events --field-selector reportingController=strimzi.io/cluster-operator显示返回的事件示例
LAST SEEN TYPE REASON OBJECT MESSAGE 2m Normal CaCertRenewed pod/strimzi-cluster-kafka-0 CA certificate renewed 58m Normal PodForceRestartOnError pod/strimzi-cluster-kafka-1 Pod needs to be forcibly restarted due to an error 5m47s Normal ManualRollingUpdate pod/strimzi-cluster-kafka-2 Pod was manually annotated to be rolled您还可以指定
reason或其他field-selector选项来限制返回的事件。在这里,添加了具体原因:
oc -n kafka get events --field-selector reportingController=strimzi.io/cluster-operator,reason=PodForceRestartOnError使用 YAML 等输出格式返回有关一个或多个事件的更多详细信息。
oc -n kafka get events --field-selector reportingController=strimzi.io/cluster-operator,reason=PodForceRestartOnError -o yaml显示详细事件输出示例
apiVersion: v1 items: - action: StrimziInitiatedPodRestart apiVersion: v1 eventTime: "2022-05-13T00:22:34.168086Z" firstTimestamp: null involvedObject: kind: Pod name: strimzi-cluster-kafka-1 namespace: kafka kind: Event lastTimestamp: null message: Pod needs to be forcibly restarted due to an error metadata: creationTimestamp: "2022-05-13T00:22:34Z" generateName: strimzi-event name: strimzi-eventwppk6 namespace: kafka resourceVersion: "432961" uid: 29fcdb9e-f2cf-4c95-a165-a5efcd48edfc reason: PodForceRestartOnError reportingController: strimzi.io/cluster-operator reportingInstance: strimzi-cluster-operator-6458cfb4c6-6bpdp source: {} type: Normal kind: List metadata: resourceVersion: "" selfLink: ""
以下字段已弃用,因此这些事件不会填充它们:
-
firstTimestamp -
lastTimestamp -
source