kubernetes runtime_error ai_generated true

错误:无法升级连接:Pod 不存在

error: unable to upgrade connection: pod does not exist

ID: kubernetes/exec-in-terminating-pod

其他格式: JSON · Markdown 中文 · English
88%修复率
85%置信度
1证据数
2023-05-10首次发现

版本兼容性

版本状态引入弃用备注
1.24 active
1.25 active
1.26 active
1.27 active
1.28 active

根因分析

尝试对处于 Terminating 状态或已被删除的 Pod 执行 exec 操作,导致 kubelet 拒绝连接升级。

English

Attempting to exec into a pod that is in Terminating state or has already been deleted, causing the kubelet to reject the connection upgrade.

generic

官方文档

https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/

解决方案

  1. Wait for pod to fully terminate, then re-create: kubectl wait --for=delete pod/<pod-name> --timeout=60s && kubectl apply -f pod.yaml
  2. Force delete the pod if stuck: kubectl delete pod <pod-name> --grace-period=0 --force, then exec into a new pod

无效尝试

常见但无效的做法:

  1. Re-running kubectl exec immediately with same pod name 95% 失败

    Pod 仍在终止中或已完全删除,重试不会改变状态

  2. Checking pod logs instead of exec 80% 失败

    日志可能已被清理或 Pod 已不存在,日志命令同样会失败

  3. Restarting kubelet on the node 90% 失败

    Pod 状态由 API Server 管理,kubelet 重启不影响已删除的 Pod