Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Make resource lookup case-insensitive to match Kubernetes API behavior#2407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Kevinz857 wants to merge1 commit intokubernetes-client:master
base:master
Choose a base branch
Loading
fromKevinz857:case-insensitive-resource-lookup-clean

Conversation

Kevinz857
Copy link
Contributor

Make Resource Lookup Case-Insensitive to Match Kubernetes API Behavior

What type of PR is this?

/kind feature
/kind bug

What this PR does / why we need it

This PR implements case-insensitive resource lookup in the dynamic client to match the actual behavior of the Kubernetes API. Currently, when using the dynamic client to look up resources, the search is case-sensitive, which causes issues when users attempt to look up resources with different casing than what's defined in the API server.

The Kubernetes API itself is case-insensitive when it comes to resource kinds. For example, bothkubectl get pod andkubectl get Pod work correctly. This PR makes the Python client's behavior consistent with the API server's behavior.

Key changes

  • Added a_find_resource_case_insensitive method to theDiscoverer class
  • Modified thesearch methods in bothLazyDiscoverer andEagerDiscoverer classes to:
    • First try exact case matching (original behavior)
    • If no match is found and a kind is specified, attempt case-insensitive lookup
    • On failure, refresh the cache and retry both strategies
  • Added test cases to verify case-insensitive lookup functionality

Special notes for your reviewer

This change is backward compatible with existing code as it maintains the same behavior for exact case matches. It only adds the additional capability to find resources when the case doesn't exactly match.

Does this PR introduce a user-facing change?

Make resource lookup case-insensitive in the dynamic client to match Kubernetes API behavior

Which issue(s) this PR fixes:

Fixes#2402

@k8s-ci-robotk8s-ci-robot added release-noteDenotes a PR that will be considered when it comes time to generate release notes. kind/featureCategorizes issue or PR as related to a new feature. kind/bugCategorizes issue or PR as related to a bug. labelsMay 31, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR isNOT APPROVED

This pull-request has been approved by:Kevinz857
Once this PR has been reviewed and has the lgtm label, please assignroycaihw for approval. For more information seethe Code Review Process.

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

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

@k8s-ci-robotk8s-ci-robot added cncf-cla: noIndicates the PR's author has not signed the CNCF CLA. size/LDenotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yesIndicates the PR's author has signed the CNCF CLA. and removed cncf-cla: noIndicates the PR's author has not signed the CNCF CLA. labelsMay 31, 2025
@roycaihw
Copy link
Member

/assign@fabianvf

@roycaihw
Copy link
Member

The Kubernetes API itself is case-insensitive when it comes to resource kinds. For example, both kubectl get pod and kubectl get Pod work correctly. This PR makes the Python client's behavior consistent with the API server's behavior.

I think the case-insensitive behavior comes from kubectl. Kubernetes API server is case sensitive. One can verify that by running kubectl with --v=9 to check the actual API request.

IIRC other clients like client-go are also case-sensitive.

/priority awaiting-more-evidence

@k8s-ci-robotk8s-ci-robot added the priority/awaiting-more-evidenceLowest priority. Possibly useful, but not yet enough support to actually get it done. labelJun 24, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fabianvffabianvfAwaiting requested review from fabianvf

@roycaihwroycaihwAwaiting requested review from roycaihw

Assignees

@fabianvffabianvf

Labels
cncf-cla: yesIndicates the PR's author has signed the CNCF CLA.kind/bugCategorizes issue or PR as related to a bug.kind/featureCategorizes issue or PR as related to a new feature.priority/awaiting-more-evidenceLowest priority. Possibly useful, but not yet enough support to actually get it done.release-noteDenotes a PR that will be considered when it comes time to generate release notes.size/LDenotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[discovery] Resource lookup is case-sensitive while it shouldn't
4 participants
@Kevinz857@k8s-ci-robot@roycaihw@fabianvf

[8]ページ先頭

©2009-2025 Movatter.jp