所有可能的 Kubernetes 事件类型
All possible Kubernetes events with type
我想对某些 Kubernetes/Openshift 事件做出反应,
因此,我需要所有可能的 (Kubernetes) 事件及其类型(正常与警告)的列表。
Openshift event list (but without type info)
事件数据示例:
{
"metadata": {
...
},
"involvedObject": {
...
},
"reason": "Created",
"firstTimestamp": "...",
"lastTimestamp": "...",
"count": 1,
"type": "Normal",
"eventTime": null,
}
事件的类型和事件的原因有关系吗?
我怎样才能create/find这么全面的列表(事件原因+类型+涉及对象种类)?
将此答案作为社区 Wiki 发布,以提供比实际解决方案更多的问题基线。随意扩展它。
我没有找到与问题中使用的 OpenShift 文档等效的 Kubernetes:
从 Kubernetes 的角度来看,您可以查看组件的源代码以了解它们可以发送哪些事件。
Kubelet
示例:
const (
FailedToKillPod = "FailedKillPod"
FailedToCreatePodContainer = "FailedCreatePodContainer"
FailedToMakePodDataDirectories = "Failed"
NetworkNotReady = "NetworkNotReady"
)
const (
CreatedContainer = "Created"
StartedContainer = "Started"
FailedToCreateContainer = "Failed"
FailedToStartContainer = "Failed"
KillingContainer = "Killing"
PreemptContainer = "Preempting"
BackOffStartContainer = "BackOff"
ExceededGracePeriod = "ExceededGracePeriod"
)
类型与事件原因之间的关系可以描述为:
// Valid values for event types (new types could be added in future)
const (
// Information only and will not cause any problems
EventTypeNormal string = "Normal"
// These events are to warn that something might go wrong
EventTypeWarning string = "Warning"
)
正如您在下面看到的,Normal
类型事件是针对不会导致任何问题的信息。 Warning
类型事件是在有问题的地方创建的(尝试下载不存在的图像:fake
):
11s Warning Failed pod/fake-f68cd66bc-hgxxv Error: ErrImagePull
11s Normal BackOff pod/fake-f68cd66bc-hgxxv Back-off pulling image "fake"
11s Warning Failed pod/fake-f68cd66bc-hgxxv Error: ImagePullBackOff
14s Normal SuccessfulCreate replicaset/fake-f68cd66bc Created pod: fake-f68cd66bc-hgxxv
14s Normal ScalingReplicaSet deployment/fake Scaled up replica set fake-f68cd66bc to 1
50s Normal Scheduled pod/nginx-6799fc88d8-ks76h Successfully assigned default/nginx-6799fc88d8-ks76h to docker-desktop
要获得集群中发生的事件的列表,您可以尝试使用 Kubernetes 集群中的专用应用程序来监视事件并将它们存储在您选择的存储选项中。
其他资源:
我想对某些 Kubernetes/Openshift 事件做出反应, 因此,我需要所有可能的 (Kubernetes) 事件及其类型(正常与警告)的列表。
Openshift event list (but without type info)
事件数据示例:
{
"metadata": {
...
},
"involvedObject": {
...
},
"reason": "Created",
"firstTimestamp": "...",
"lastTimestamp": "...",
"count": 1,
"type": "Normal",
"eventTime": null,
}
事件的类型和事件的原因有关系吗?
我怎样才能create/find这么全面的列表(事件原因+类型+涉及对象种类)?
将此答案作为社区 Wiki 发布,以提供比实际解决方案更多的问题基线。随意扩展它。
我没有找到与问题中使用的 OpenShift 文档等效的 Kubernetes:
从 Kubernetes 的角度来看,您可以查看组件的源代码以了解它们可以发送哪些事件。
Kubelet
示例:
const (
FailedToKillPod = "FailedKillPod"
FailedToCreatePodContainer = "FailedCreatePodContainer"
FailedToMakePodDataDirectories = "Failed"
NetworkNotReady = "NetworkNotReady"
)
const (
CreatedContainer = "Created"
StartedContainer = "Started"
FailedToCreateContainer = "Failed"
FailedToStartContainer = "Failed"
KillingContainer = "Killing"
PreemptContainer = "Preempting"
BackOffStartContainer = "BackOff"
ExceededGracePeriod = "ExceededGracePeriod"
)
类型与事件原因之间的关系可以描述为:
// Valid values for event types (new types could be added in future)
const (
// Information only and will not cause any problems
EventTypeNormal string = "Normal"
// These events are to warn that something might go wrong
EventTypeWarning string = "Warning"
)
正如您在下面看到的,Normal
类型事件是针对不会导致任何问题的信息。 Warning
类型事件是在有问题的地方创建的(尝试下载不存在的图像:fake
):
11s Warning Failed pod/fake-f68cd66bc-hgxxv Error: ErrImagePull
11s Normal BackOff pod/fake-f68cd66bc-hgxxv Back-off pulling image "fake"
11s Warning Failed pod/fake-f68cd66bc-hgxxv Error: ImagePullBackOff
14s Normal SuccessfulCreate replicaset/fake-f68cd66bc Created pod: fake-f68cd66bc-hgxxv
14s Normal ScalingReplicaSet deployment/fake Scaled up replica set fake-f68cd66bc to 1
50s Normal Scheduled pod/nginx-6799fc88d8-ks76h Successfully assigned default/nginx-6799fc88d8-ks76h to docker-desktop
要获得集群中发生的事件的列表,您可以尝试使用 Kubernetes 集群中的专用应用程序来监视事件并将它们存储在您选择的存储选项中。
其他资源: