json - 所有可能的 Kubernetes 事件及其类型

标签 json api kubernetes events openshift

我想对某些 Kubernetes/Openshift 事件使用react, 因此,我需要所有可能的(Kubernetes)事件及其类型(正常与警告)的列表。

Openshift event list (but without type info)

事件数据示例:

   {
      "metadata": {
         ...
      },
      "involvedObject": {
         ...
      },
      "reason": "Created",
      "firstTimestamp": "...",
      "lastTimestamp": "...",
      "count": 1,
      "type": "Normal",
      "eventTime": null,
    }

事件的类型和原因之间有什么关系吗?

如何创建/查找这样一个全面的列表(事件原因+类型+涉及对象种类)?

最佳答案

将此答案发布为社区 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 集群内的专用应用程序来监视事件并将它们存储在您选择的存储选项中。


其他资源:

关于json - 所有可能的 Kubernetes 事件及其类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66687989/

相关文章:

kubernetes - Knative Serving 的 Activator 如何拦截缩小修订的请求?

docker - docker 标签和kubernetes标签之间的区别?

kubernetes - 将外部节点添加到 GCP Kubernetes 集群

php - 根据 Jquery Ajax 返回的值填充第二个下拉列表

c - 使用 jsonc 库在 C 中追加 json_object_arrays

javascript - 当我按下任何按钮而不编辑该文本字段但光标位于该文本字段时停止 api 调用

api - Pinterest API v3 OAuth 仍然有效吗?

java - Jersey 在序列化期间省略 XmlTransient 注释

javascript - Highcharts:创建具有堆叠行的甘特图

android - 移动应用程序中的用户身份验证