Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Kubectl exec: "Error from server (BadRequest): Upgrade request required"
I'm getting an error when trying to open a shell to a pod. This used to work.
$ kubectl exec --tty --stdin --namespace my-ns my-pod -- sh
Error from server (BadRequest): Upgrade request required
What does it mean?
1 answer
Ok I got it working again.
The issue was that I had updated my kubeconfig file, and the current-context
setting had changed. This setting essentially selects which cluster kubectl targets.
Now the cluster wasn't a wrong one per se, it just wasn't a direct route. This is a rancher
managed cluster [1], meaning that by default the rancher servers will proxy traffic from kubectl to the actual cluster. It apparently doesn't support proxying websockets, at least without additional configuration.
You can enable the authorized cluster endpoint feature to bypass rancher and connect directly to the cluster, in which case websockets work just fine. You just need to remember to select the correct context in kubectl..
You can view your contexts and select the active one like this from cli:
$ kubectl config view
$ kubectl config set-context my-new-context
-
There's probably a risk of this happening with other proxies as well. ↩︎
1 comment thread