Skip to content

Commit 16cc959

Browse files
committed
fix(py3-kubernetes): cherry-pick v36 incluster auth fix + regression test
v36.0.0 rewrote Configuration.auth_settings() to look up the bearer credential under api_key['BearerToken'], but left the hand-written loaders in kubernetes/base/config/ and kubernetes_asyncio/config/ writing api_key['authorization']. Net effect: every load_incluster_config() on v36 produces a Configuration with no bearer credential, requests go out unauthenticated, and the apiserver rejects them as system:anonymous. Cherry-pick the two upstream commits from PR #2585 to write 'BearerToken' in all three loaders, and bump epoch to 1. Drop the cherry-picks once a v36.0.1 upstream release ships with the fix applied. Also add a subpackage test that drives InClusterConfigLoader._set_config and asserts api_key['BearerToken'] is populated, so the fix can't be silently dropped on a future bump. Refs: - Upstream PR: kubernetes-client/python#2585 - Upstream issue: kubernetes-client/python#2591 Signed-off-by: Francesco Bartolini <francesco.bartolini@chainguard.dev> Export: 6f0eda5c49c32b1ea5cb945c2c36e44ec0c20d35
1 parent df4f246 commit 16cc959

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

py3-kubernetes.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package:
22
name: py3-kubernetes
33
version: "36.0.0"
4-
epoch: 0
4+
epoch: 1
55
description: Kubernetes python client
66
copyright:
77
- license: Apache-2.0
@@ -40,6 +40,9 @@ pipeline:
4040
repository: https://github.com/kubernetes-client/python
4141
tag: v${{package.version}}
4242
expected-commit: 97290c49c18ca84c831068ddb887092353719b3f
43+
cherry-picks: |
44+
master/c3608a4c2b1f046f6ffd8effeca4cafeead70d5b: config write api_key BearerToken so v36+ SDK auth works
45+
master/7cc2c579516839d373065f1ec7d19dcc692360f6: config drop dual-write replace authorization with BearerToken
4346
4447
subpackages:
4548
- range: py-versions
@@ -74,6 +77,23 @@ subpackages:
7477
with:
7578
python: python${{range.key}}
7679
import: ${{vars.pypi-package}}
80+
- name: incluster loader sets BearerToken api_key
81+
runs: |
82+
python${{range.key}} - <<'PY'
83+
from kubernetes.client import Configuration
84+
from kubernetes.config.incluster_config import InClusterConfigLoader
85+
86+
loader = InClusterConfigLoader.__new__(InClusterConfigLoader)
87+
loader.host = "https://test.invalid"
88+
loader.token = "test-token"
89+
loader.ssl_ca_cert = None
90+
loader._try_refresh_token = False
91+
92+
cfg = Configuration()
93+
loader._set_config(cfg)
94+
95+
assert cfg.api_key.get("BearerToken") == "test-token", cfg.api_key
96+
PY
7797
7898
- name: py3-supported-${{vars.pypi-package}}
7999
description: meta package providing ${{vars.pypi-package}} for supported python versions.

0 commit comments

Comments
 (0)