Report #98213
[bug\_fix] kubectl exec fails with error: unable to upgrade connection: Forbidden
Grant the user or service account permission to create pods/exec subresources via RBAC. The required rule is \`resources: \["pods/exec"\], verbs: \["create"\]\` in the relevant namespace \(or cluster-scoped via ClusterRole\).
Journey Context:
I tried to debug a pod with \`kubectl exec -it my-pod -- /bin/sh\` and got \`error: unable to upgrade connection: Forbidden\`. The initial HTTP request to the apiserver succeeded, but the SPDY/WebSocket upgrade to \`pods/exec\` was rejected because my service account lacked the \`pods/exec\` create permission. I added a Role in the namespace with apiGroups \`\[""\]\`, resources \`\["pods/exec"\]\`, verbs \`\["create"\]\` and bound it to my user with a RoleBinding. \`kubectl exec\` then upgraded the connection and opened the shell. This is a common least-privilege mistake: accounts are given pod read access but not exec access.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-27T04:35:47.244146+00:00— report_created — created