`sec-websocket-protocol` header defaults to `v4.channel.k8s.io` causing HTTP 400
@seans3 ya está trabajando en esto.
Desde el 26/2/2025.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
What happened (please include outputs or screenshots):
We are running our tool Gefyra to fetch environment variables from a running pod/container via a usual stream over connect_get_namespaced_pod_exec:
In one of our environments, I am receiving an HTTP 400 for the WebSocket upgrade call. However, the equivalent kubectl exec ... executes properly.
From somewhere in the stack trace: websocket._exceptions.WebSocketBadStatusException: Handshake status 400 Bad Request - ...
So I looked for the differences between kubectl (v1.31.1) and the Python package (31.0.0). I was able to trace the problem back to the sec-websocket-protocol header, which defaults to v4.channel.k8s.io
The value of the sec-websocket-version is set to 13 with both kubectl and kubernetes-python.
Unfortunately, I couldn't find many sources on this, except https://kubernetes.io/blog/2024/08/20/websockets-transition/.
After patching the content of kubernetes/base/stream/ws_client.py in my site-packages to v5.channel.k8s.io it started to work again.
Now I am looking for a solution to pass this header from our code to get rid of the monkeypatch, but without constructing the WSClient myself.
Is this some special setting in our environment (I mean to prevent v4.channel.k8s.io from working) or does that apply to all K8s clusters starting from 1.30.x?
What you expected to happen:
The stream over connect_get_namespaced_pod_exec to work with sec-websocket-protocol set to v5.channel.k8s.io.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
- Kubernetes version (
kubectl version):
Client Version: v1.31.1
Kustomize Version: v5.4.2
Server Version: v1.30.1
- OS (e.g., MacOS 10.13.6):
Linux/Container
- Python version (
python --version)
Python 3.9.20
- Python client version (
pip list | grep kubernetes)
kubernetes 31.0.0
Thank you for your good work.
- Lenguaje dominante
- Python
- Estrellas
- 7.7k
- Forks
- 3.5k
- Merge medio
- 1 d 14 h
- PR fusionados (30 d)
- 18
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de kubernetes-client/python
-
kind/bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
kubernetes-client/python#2280 · 16 comentarios · 9 reacciones ·
-
Release 1.37 Abierto
kubernetes-client/python#2691 · 1 comentario · 1 reacción · 1 asignado ·
-
Growing library size Abiertohelp wanted
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
kubernetes-client/python#2677 · 13 comentarios · 1 reacción ·
-
help wanted kind/feature
kubernetes-client/python#2602 · 6 comentarios · 1 asignado ·
-
kind/bug
kubernetes-client/python#2596 · 13 comentarios · 2 reacciones · 1 asignado ·
Todos los issues de kubernetes-client/python
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
browser-use/browser-use#5905 ·
-
type: enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ynput/ayon-python-api#363 ·
-
bug needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
modelscope/FunASR#3728 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
open-compass/opencompass#2655 ·