You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
容器的资源消耗:Sidecar 容器可能会消耗大量资源(如 CPU、内存),从而影响 Pod 的整体性能和稳定性。如果资源分配不合理,可能导致资源争用,影响 Pod 的稳定性。例如,一个监控 Sidecar 容器消耗过多内存,导致主应用容器的内存不足,从而触发 Pod 的 OOM(Out Of Memory)情况;
终止信号的处理:Kubernetes 在终止 Pod 时,会向所有容器发送终止信号,并等待它们优雅地关闭。如果 Sidecar 容器关闭时间较长或无法正确处理终止信号,可能延迟整个 Pod 的终止过程。例如,一个代理 Sidecar 容器在接收到终止信号后需要较长时间关闭,可能会导致 Pod 无法及时释放资源,影响集群的调度效率。
Pod 的状态
Pod 的阶段(phase)
PodPhase 是一个字符串别名:
type PodPhase string
,是pod当前 condition 的一个描述,包括 Pending、Running、Succeeded、Failed、Unknown 1:从这些描述中,我们可以看出 Pod 和 Container 的关系很紧密。
Pod ReadinessGate
ReadinessGate 影响Pod是否就绪的判断,Pod就绪则会被认为可以接受请求。使用方法是在 Pod 的 .spec.readinessGates 加入 kv,它是一个数组,允许多个条件同时满足才被认定为 ready,例如:
kubectl patch方法不支持修改 status,只能用 client-go 之类的 sdk 编程实现,如通过 controller。如果一个 Pod 使用了自定义 condition,只有满足以下条件,Pod才能被认定为 ready:
如果 container 都已ready,但 readiness gates 并不都为 True,那么 Pod 状态将是 ContainersReady
与 ReadinessProbe 的不同
注意 k8s 的 ReadinessProbe(就绪探针)和 ReadinessGate 没有直接关系,但只有它俩都 ready,Pod才会被认定为可以接收请求。ReadinessProbe 支持 HTTP、RPC、执行脚本来确定某个Pod是否 ready:
说明:
容器的状态(Status)
类型定义参见 2:
Pod 或 容器 的异常状态 3
不明确状态有 Terminating、Pending、ContainerCreating、Waiting
异常状态有
Pod Condition
PodCondition 是 pod 的状况,phase 是对 condition 的标签
PodCondition 有如下几个:
抢占(preemption)
、驱逐(eviction)
或GC(garbage-collection)
Sidecar 容器对 Pod Condition 和 Ready 判断的影响
Footnotes
https://kubernetes.io/zh-cn/docs/concepts/workloads/pods/pod-lifecycle/ ↩
/~https://github.com/kubernetes/kubernetes/blob/16a594f907d0d4a6224dab2d0704793d5e7898f6/pkg/apis/core/types.go#L2678 ↩
https://imroc.cc/kubernetes/troubleshooting/pod/index.html ↩
The text was updated successfully, but these errors were encountered: