kubernetes
runtime_error
ai_generated
true
error: unable to upgrade connection: pod does not exist
ID: kubernetes/exec-in-terminating-pod
88%Fix Rate
85%Confidence
1Evidence
2023-05-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.24 | active | — | — | — |
| 1.25 | active | — | — | — |
| 1.26 | active | — | — | — |
| 1.27 | active | — | — | — |
| 1.28 | active | — | — | — |
Root Cause
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中文
尝试对处于 Terminating 状态或已被删除的 Pod 执行 exec 操作,导致 kubelet 拒绝连接升级。
Official Documentation
https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/Workarounds
-
85% success Wait for pod to fully terminate, then re-create: kubectl wait --for=delete pod/<pod-name> --timeout=60s && kubectl apply -f pod.yaml
Wait for pod to fully terminate, then re-create: kubectl wait --for=delete pod/<pod-name> --timeout=60s && kubectl apply -f pod.yaml
-
90% success Force delete the pod if stuck: kubectl delete pod <pod-name> --grace-period=0 --force, then exec into a new pod
Force delete the pod if stuck: kubectl delete pod <pod-name> --grace-period=0 --force, then exec into a new pod
中文步骤
Wait for pod to fully terminate, then re-create: kubectl wait --for=delete pod/<pod-name> --timeout=60s && kubectl apply -f pod.yaml
Force delete the pod if stuck: kubectl delete pod <pod-name> --grace-period=0 --force, then exec into a new pod
Dead Ends
Common approaches that don't work:
-
Re-running kubectl exec immediately with same pod name
95% fail
Pod 仍在终止中或已完全删除,重试不会改变状态
-
Checking pod logs instead of exec
80% fail
日志可能已被清理或 Pod 已不存在,日志命令同样会失败
-
Restarting kubelet on the node
90% fail
Pod 状态由 API Server 管理,kubelet 重启不影响已删除的 Pod