Repository navigation
Description
What happened
Upgrading from kubernetes==35.0.0 to kubernetes==36.0.0 causes every API request that relies on a Bearer token (the in-cluster ServiceAccount auth path, or any caller that sets Configuration.api_key['authorization'] directly) to be sent without an Authorization header. The server treats the request as system:anonymous and rejects it (401 on AKS, 403 on minikube).
Minimal reproducer
Direct check of the method the generated API operations call to attach auth headers before sending HTTP requests:
from kubernetes import client
cfg = client.Configuration()
cfg.api_key['authorization'] = 'Bearer fake-token'
api = client.ApiClient(cfg)
headers = {}
api.update_params_for_auth(headers, [], ['BearerToken'])
print('headers:', headers)Expected output (matches v35.0.0)
headers: {'authorization': 'Bearer fake-token'}
Actual output on v36.0.0
headers: {}
The Bearer-token-aware code path is silently a no-op. The HTTP request goes out with no Authorization header and the server treats it as system:anonymous.
Supporting evidence
Configuration.auth_settings() - which update_params_for_auth reads to find scheme definitions - is also empty on v36:
>>> cfg.auth_settings() # v35: {'BearerToken': {...}}
{} # v36So the regression is at the Configuration level: the BearerToken scheme entry that should be present in auth_settings() (and is in v35) is missing in v36, which cascades into update_params_for_auth having nothing to apply.
Impact
Any pod doing in-cluster API calls via this library is broken on v36.0.0 - including (but not limited to) callers of CoordinationV1Api, CoreV1Api, etc. We caught this when our Lease-coordinated workload pods started failing every read_namespaced_lease call with 401 immediately after a rebuild upgraded the lib from v35 to v36.
Environment
kubernetes==36.0.0(uploaded to PyPI 2026-05-20T20:44Z)- Python 3.12 / 3.13 (reproduced on both)
- Linux container (also reproduced on macOS in a clean venv)
Regression window
The bug is present in the entire 36-series:
| Version | PyPI upload | update_params_for_auth result |
|---|---|---|
| v35.0.0 | 2026-01-16 | populates {'authorization': 'Bearer ...'} |
| v36.0.0a3 | 2026-05-08 | empty {} (regression introduced here) |
| v36.0.0b1 | 2026-05-13 | empty {} |
| v36.0.0 | 2026-05-20 | empty {} |
So the regression was present from the first 36-series prerelease and shipped to stable without a fix. The diff between v35.0.0..v36.0.0a3 should contain the offending change.
Workaround
Pin kubernetes>=29,<36 until a v36 patch ships.
Hypothesis (haven't dug in further)
This looks like the OpenAPI/swagger-driven code generation for Configuration regressed - the dict literal that defines the BearerToken entry under auth_settings() likely got dropped or scoped out. Worth diffing the generated Configuration class between v35.0.0 and v36.0.0.
Activity
[-]`Configuration.auth_settings()` returns empty dict in v36.0.0 - all BearerToken-authed requests go anonymous`[/-][+]`Configuration.auth_settings()` returns empty dict in v36.0.0 - all BearerToken-authed requests go anonymous[/+]fix(mdns-advertiser): pin kubernetes client to 35.0.0 to avoid auth r…
jhostetler commentedon May 21, 2026
Also experiencing this issue. Requests to create resources succeed using version
35.0.0but raise a 403 with36.0.0Pin kubernetes<36 to fix runner 401s against the K8s API (#448)
fix(deps): address review — use !=36.* pin, regenerate lock with uv v2
fix(ingestion): cap kubernetes client below 36.0.0 (#28331)
fix(ingestion): cap kubernetes client below 36.0.0 (#28331)
fix(ingestion): cap kubernetes client below 36.0.0 (#28331)
[Kubernetes] Pin kubernetes<36 due to RBAC regression from the package (
MaZderMind commentedon May 21, 2026
Works like this with 36.0.0:
jmacek commentedon May 21, 2026
Thanks, that workaround is useful - confirmed it works on a clean v36.0.0 venv.
Worth being clear that it's a workaround, not the intended path. Diffing v35.0.0 vs v36.0.0 makes the mismatch concrete:
kubernetes/client/configuration.py::auth_settings()was changed to look up the bearer auth under a renamed key:Manual construction with
api_key={"BearerToken": ...}+api_key_prefix={"BearerToken": "Bearer"}(what your snippet does) is the intended new API for that key, and it works.What appears to have been missed is updating the loader side to match.
kubernetes/base/config/incluster_config.pyis byte-identical between v35.0.0 and v36.0.0 and still writes the old key:kube_config.pyhas the same issue at line 542 (only unrelated changes between v35/v36 - the adal removal). Soauth_settings()was renamed without the two canonical entry points being updated to write the new key. The result is that any caller usingload_incluster_config()orload_kube_config()on v36 gets unauthenticated requests with no error - the Authorization header is silently dropped.For folks pinned to v36 who can't change their
load_incluster_config()callsites, the equivalent post-load fix is:Same idea as yours, adapted to patch the Configuration after
load_incluster_config()writes the stale shape. Pinningkubernetes<36also works if a code change isn't an option - and is probably the safer choice short-term since the workaround becomes dead code onceload_incluster_config()is fixed upstream.Proper fix would be either updating
load_incluster_config()(andload_kube_configfor parity) to write the new shape, or makingauth_settings()accept the old shape as a fallback. I'll put up a PR with the loader-side fix shortly.[Kubernetes] Pin kubernetes<36 due to RBAC regression from the package (
fix(deps): address review — use !=36.* pin, regenerate lock with uv v2
feat: Add skill linking support for agents (#1440)
fix: exclude kubernetes client 36.0.0 due to anonymous auth bug
fix(deps): pin kubernetes<36 due to broken bearer-token auth (#2730)
fix: pin kubernetes!=36.0.0 due to broken bearer-token auth (#2733)
fix(deps): pin kubernetes!=36.0.0 due to broken bearer-token auth (#2732
fix(deps): pin kubernetes!=36.0.0 due to broken bearer-token auth (#2731
chore: Pin kubernetes below v36 to avoid breaking API changes (#259)
Sync 2026-06-01 : Main upstream (#2)
Allow kubernetes and kubernetes_asyncio client 36.x in cncf.kubernetes
Allow kubernetes and kubernetes_asyncio client 36.x in cncf.kubernetes
Allow kubernetes and kubernetes_asyncio client 36.x in cncf.kubernetes (
Cap kubernetes client to <36 to fix cluster auth 401 regression
anastasiyatolstikenableu commentedon Jun 30, 2026
Pinned
kubernetes==35.0.0to keep the operator image on the last verified working Kubernetes Python client version.We compared the images:
kubernetes==35.0.0kubernetes==36.0.2With
36.0.2, Kopf logs authentication as successful, but Kubernetes API requests are handled assystem:anonymous. This is similar to the upstream regression described in #2592. Although that issue is marked fixed upstream, we still reproduce the behavior with36.0.2in our operator image, so we pin to35.0.0until a newer client version is verified in our cluster.Thank you!
Allow kubernetes and kubernetes_asyncio client 36.x in cncf.kubernete…