概述
Kubernetes 事件(Event)是 Kubernetes 系统中的重要信息源,用于记录集群中各种资源状态变化和系统组件活动。事件提供了对集群内部运行状况的可见性,帮助管理员诊断和监控系统行为。
事件类型
| 类型 | 含义 | 示例 | 特点 |
|---|---|---|---|
| Normal(正常类型) | 表示正常的系统操作或预期行为 | Pod调度成功、容器创建成功、配置更新完成 | 通常不需要立即干预,用于跟踪系统状态 |
| Warning(警告类型) | 表示异常情况或需要关注的问题 | 调度失败、容器崩溃、资源不足 | 需要监控和排查,可能影响系统稳定性 |
常见事件说明
Pod相关事件
| 事件名称 | 类型 | 说明 | 消息示例 | 常见原因/场景 |
|---|---|---|---|---|
| Scheduled | Normal | Pod成功调度到节点 | Successfully assigned default/my-pod to node-01 | Pod创建后正常调度 |
| FailedScheduling | Warning | Pod调度失败 | 0/3 nodes are available: 1 Insufficient cpu, 2 node(s) had taint {key:value} | 1. 节点资源不足(CPU/内存) 2. 节点污点不匹配 3. 节点选择器不满足 |
| Pulling | Normal | 正在拉取容器镜像 | Pulling image “nginx:latest” | 容器启动前拉取镜像 |
| Pulled | Normal | 镜像拉取成功 | Successfully pulled image “nginx:latest” | 镜像拉取完成 |
| Created | Normal | 容器创建成功 | Created container “nginx” | 容器实例已创建 |
| Started | Normal | 容器启动成功 | Started container “nginx” | 容器进程已启动 |
| Failed | Warning | 容器启动失败 | Failed to pull image “invalid-image”: Error response from daemon: pull access denied | 1. 镜像不存在 2. 镜像仓库认证失败 3. 网络连接问题 |
| BackOff | Warning | 容器启动失败,正在重试 | Back-off pulling image “private-registry/image” | 镜像拉取失败后的重试状态 |
| Unhealthy | Warning | 健康检查失败 | Liveness probe failed: Get “http://:8080/healthz”: dial tcp connection refused | 1. 应用未正确启动 2. 探针配置不正确 3. 应用响应超时 |
| Killing | Normal | 容器被终止 | Killing container with id docker://nginx:Need to kill Pod | Pod被删除、资源回收、节点维护 |
节点相关事件
| 事件名称 | 类型 | 说明 | 消息示例 | 常见原因 |
|---|---|---|---|---|
| NodeNotReady | Warning | 节点状态变为不可用 | Node node-01 is not ready | 1. Kubelet服务停止 2. 节点资源耗尽 3. 网络连接中断 4. 系统负载过高 |
| NodeReady | Normal | 节点恢复正常状态 | Node node-01 is now ready | 节点故障恢复后 |
| NodeHasInsufficientMemory | Warning | 节点内存不足 | Node node-01 status is now: NodeHasInsufficientMemory | 内存资源紧张 |
| NodeHasDiskPressure | Warning | 节点磁盘压力 | Node node-01 status is now: NodeHasDiskPressure | 磁盘空间不足或inode耗尽 |
| NodeHasPIDPressure | Warning | 节点PID资源紧张 | Node node-01 status is now: NodeHasPIDPressure | PID资源耗尽 |
存储相关事件
| 事件名称 | 类型 | 说明 | 消息示例 | 常见原因 |
|---|---|---|---|---|
| FailedMount | Warning | 存储卷挂载失败 | Unable to mount volumes for pod: timeout expired waiting for volumes to attach | 1. 存储插件未就绪 2. 网络存储连接超时 3. 权限配置错误 4. StorageClass配置问题 |
| FailedAttachVolume | Warning | 卷附加失败 | AttachVolume.Attach failed for volume “pvc-123”: volume not found | 存储卷不存在或不可用 |
| SuccessfulCreateVolume | Normal | 持久卷创建成功 | Successfully provisioned volume pvc-123 using storage-class standard | 动态存储供应成功 |
控制器相关事件
| 事件名称 | 类型 | 说明 | 消息示例 | 常见原因 |
|---|---|---|---|---|
| ScalingReplicaSet | Normal | 副本集扩缩容 | Scaled up replica set my-app-123 from 0 to 3 | Deployment扩缩容操作 |
| ProgressDeadlineExceeded | Warning | Deployment更新超时 | ReplicaSet “my-app-123” has timed out progressing | 1. 新Pod启动失败 2. 就绪探针持续失败 3. 资源不足 |
| SuccessfulCreate | Normal | 成功创建Pod副本 | Created pod: my-app-123-abc | ReplicaSet创建Pod成功 |
| FailedCreate | Warning | 创建Pod副本失败 | Error creating: pods “my-app” is forbidden | 1. 资源配额限制 2. 安全策略限制 3. 命名空间限制 |
服务相关事件
| 事件名称 | 类型 | 说明 | 消息示例 | 常见原因 |
|---|---|---|---|---|
| FailedToCreateEndpoint | Warning | 服务端点创建失败 | Failed to create endpoint for service my-service: endpoints “my-service” is forbidden | 1. Pod标签与选择器不匹配 2. 网络策略限制 3. 权限问题 |
| TypeChanged | Normal | 服务类型变更 | Service type changed from ClusterIP to LoadBalancer | 服务配置变更 |
配置相关事件
| 事件名称 | 类型 | 说明 | 消息示例 | 影响 |
|---|---|---|---|---|
| Updated | Normal | 配置更新成功 | Updated config map my-config | 使用该ConfigMap的Pod会收到更新 |
| FailedToUpdate | Warning | 配置更新失败 | Error updating secret my-secret: secrets “my-secret” is forbidden | 配置无法应用 |
资源配额事件
| 事件名称 | 类型 | 说明 | 消息示例 | 常见限制 |
|---|---|---|---|---|
| FailedQuota | Warning | 超出资源配额限制 | Pod “my-pod” is forbidden: exceeded quota: default-quota | 1. CPU/内存请求限制 2. 持久卷声明数量 3. 服务数量 4. Pod数量 |
关键事件快速参考表
| 事件名称 | 类型 | 关键组件 | 紧急程度 | 常见处理 |
|---|---|---|---|---|
| FailedScheduling | Warning | Scheduler | 高 | 检查节点资源、污点、选择器 |
| BackOff | Warning | Kubelet | 中 | 检查镜像、应用启动日志 |
| Unhealthy | Warning | Kubelet | 中 | 检查探针配置、应用状态 |
| FailedMount | Warning | Kubelet | 高 | 检查存储配置、网络连接 |
| NodeNotReady | Warning | Controller | 高 | 检查节点状态、Kubelet服务 |
| FailedCreate | Warning | Controller | 中 | 检查资源配额、安全策略 |
| ProgressDeadlineExceeded | Warning | Deployment | 中 | 检查新Pod状态、就绪探针 |
作者:叶奕珺 创建时间:2025-12-30 10:33
最后编辑:叶奕珺 更新时间:2026-01-15 14:15
最后编辑:叶奕珺 更新时间:2026-01-15 14:15