Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy support to connect to clusters, upgrade gen to OpenAPI 7.1.0 client #2147

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rolf-moz
Copy link

@rolf-moz rolf-moz commented Nov 15, 2023

What type of PR is this?

/kind feature
This a feature addition to start supporting the 'proxy-url' field in the kubernetes config files.
This will support most proxies. An upcoming version of OpenAPI generator will support Socks proxies as well.

Additionally this PR has changes that the support 7.x OpenAPI generator.

Fixes: #1967

Special notes for your reviewer:

Note this Socks5 support is dependent on a recently merged update I made to OpenAPI generator to support Socks5 proxies: OpenAPITools/openapi-generator#16918 that will be in the upcoming 7.2 release.

For now the python.sh in the gen project (that auto-generates the full client) should be updated to use 7.1.0. Example:
OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v7.1.0}"

A sample generated project is visible here
https://github.com/rolf-moz/kubernetes-client-python/tree/feat/add-proxy-support-gen

Does this PR introduce a user-facing change?

Yes

Added support for the 'proxy-url' cluster setting in kube config files, including support for proxies . 

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

Proxy support.

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Nov 15, 2023
Copy link

linux-foundation-easycla bot commented Nov 15, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Nov 15, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @rolf-moz!

It looks like this is your first PR to kubernetes-client/python 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/python has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 15, 2023
@rolf-moz rolf-moz changed the title read proxy config for cluster and add to openapi config Add proxy support, including Socks5 proxy, to connect to clusters Nov 16, 2023
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 17, 2023
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 25, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rolf-moz
Once this PR has been reviewed and has the lgtm label, please assign roycaihw for approval. For more information see the Kubernetes Code Review Process.

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

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

@rolf-moz rolf-moz changed the title Add proxy support, including Socks5 proxy, to connect to clusters Add proxy support to connect to clusters, upgrade gen to OpenAPI 7.1.0 client Nov 25, 2023
@roycaihw
Copy link
Member

For now the python.sh in the gen project (that auto-generates the full client) should be updated to use 7.1.0. Example:
OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v7.1.0}"

The version is the gen project is actually not honored. This client overrides the value here.

Copy link
Member

@roycaihw roycaihw left a comment

Choose a reason for hiding this comment

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

The change looks good to me. Should we wait for this project to be upgrade to OpenAPI 7.1.0+ first?

@rolf-moz
Copy link
Author

rolf-moz commented Nov 28, 2023

The change looks good to me. Should we wait for this project to be upgrade to OpenAPI 7.1.0+ first?

@roycaihw
Actually several changes I made are fixes for the OpenAPI 7.1 gen compatibility. One thing I could do is a separate PR for the OpenAPI 7.1.0 support first, and then redo this pr once that gets approved.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 2, 2023
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 9, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 8, 2024
@UnsolvedCypher
Copy link

@roycaihw I just wanted to follow up as I think this PR is important. Is it good to merge as-is or would you like to split it up between the adding of OpenAPI 7.1.0 support and the actual upgrade?

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 26, 2024
@UnsolvedCypher
Copy link

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label May 26, 2024
@PhroZenOne
Copy link

I'm are using ansible k8s to connect to a cluster but we need to be able to connect over socks5, If I understand the stacktrace and the discussion in this PR, this contains the stuff I am looking for. :)

urllib3.exceptions.ProxySchemeUnknown: Proxy URL had unsupported scheme socks5, should use http:// or https://

Anything I can do to help here? @roycaihw @rolf-moz

@rolf-moz
Copy link
Author

@PhroZenOne yes if you want to rebase you can. I might have time later this week too.

I'm not up to date... is kubernetes client using 7.x openapi generator yet?

If you'd like to try a built library with this support you can use https://github.com/rolf-moz/kubernetes-client-python/tree/feat/add-proxy-support-gen and let me know how it works for you.

@PhroZenOne
Copy link

@rolf-moz Did a rebase, PR here: #2255 Please have a look.

If you want to update your PR with this I can close mine so we keep this in one place.

@PhroZenOne
Copy link

Hm, there are API changes with the newer kubernetes API that breaks when testing so my branch will not work:

     File .../kubernetes/dynamic/client.py", line 273, in request
    api_response = self.client.call_api(
TypeError: ApiClient.call_api() got multiple values for argument 'body'

I dont have more time to spend on this right now I'm afraid so for now I will give up. I might have more time next month to look at it.

@PhroZenOne
Copy link

Made some changes to client.py to make it work again for my use case, but I have no idea if this is a good solution: PhroZenOne@97c36c3

@rolf-moz
Copy link
Author

@PhroZenOne @roycaihw Ok looks like this branch is getting some use. Let me see if I can update this PR later today to be up to date with main

@kwibus
Copy link

kwibus commented Oct 16, 2024

Would be really nice if this pull request would be merged would also help with:
#2183

Made pull request for proxy_url before, but it got ignored. But it also include some tests. You could use that if you want.
https://github.com/kubernetes-client/python/pull/2182/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client not able to reach Cluster API behind a proxy if using multiple client function
7 participants