Skip to content

fix: support kubernetes client v35-v36 token keys#33

Merged
mprahl merged 1 commit into
kubeflow:mainfrom
kramaranya:fix-bearertoken-k8s-v36
Jul 7, 2026
Merged

fix: support kubernetes client v35-v36 token keys#33
mprahl merged 1 commit into
kubeflow:mainfrom
kramaranya:fix-bearertoken-k8s-v36

Conversation

@kramaranya

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:
The Kubernetes Python client changed bearer token handling between v35 and v36.

  • v29-v35 expect api_key["authorization"]
  • v36 expects api_key["BearerToken"]
  • v36.0.2 restores partial backward compatibility, but manual Configuration() objects still miss the Bearer prefix when only the legacy key is set

This change sets both keys and both prefixes when constructing the temporary client used for SelfSubjectAccessReview, so requests authenticate correctly across supported client versions.

Related Issues/PRs (use Fixes #<number> to auto-close, or Relates to #<number>):

How is this PR tested?

  • Existing unit tests
  • New unit tests
  • Manual testing

Does this PR require documentation update?

  • No
  • Yes (updated docs/ or README)

Checklist:

  • Commits are signed off (DCO)
  • Pre-commit hooks pass (pre-commit run --all-files)
  • Tests pass (make python-test)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Kubernetes authorization plugin’s temporary Kubernetes ApiClient construction so SelfSubjectAccessReview authentication works across Kubernetes Python client versions v35 and v36, which use different Configuration.api_key scheme names for bearer tokens.

Changes:

  • Set both legacy (api_key["authorization"]) and v36+ (api_key["BearerToken"]) token entries on the temporary Configuration.
  • Set api_key_prefix for both keys to ensure the Bearer prefix is applied consistently across client versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +245 to +249
# Set both legacy ('authorization') and v36+ ('BearerToken') keys.
# kubernetes-client/python still has a compatibility gap across v35-v36
# for manually constructed Configuration objects; see issues #2592 and PR #2618.
configuration.api_key = {"BearerToken": token, "authorization": token}
configuration.api_key_prefix = {"BearerToken": "Bearer", "authorization": "Bearer"}
Signed-off-by: kramaranya <kramaranya15@gmail.com>
@kramaranya kramaranya force-pushed the fix-bearertoken-k8s-v36 branch from 3d77f5a to ee9240f Compare July 7, 2026 12:02
@google-oss-prow google-oss-prow Bot added size/M and removed size/XS labels Jul 7, 2026

@mprahl mprahl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mprahl

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mprahl

mprahl commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

The test failures are due to needing to rebase. I'll merge it though since this is a small change.

@mprahl mprahl merged commit 8857e54 into kubeflow:main Jul 7, 2026
6 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants