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

Client not able to reach Cluster API behind a proxy if using multiple client function #1967

Closed
FlorianJDF opened this issue Dec 12, 2022 · 7 comments · Fixed by #1968 · May be fixed by #2147
Closed

Client not able to reach Cluster API behind a proxy if using multiple client function #1967

FlorianJDF opened this issue Dec 12, 2022 · 7 comments · Fixed by #1968 · May be fixed by #2147
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@FlorianJDF
Copy link
Contributor

Hello all,

What happened (please include outputs or screenshots):
I need to access multiple k8s clusters at once, all behind a proxy.
To be able to reach many k8s clusters at once, I use the function new_client_from_config_dict.

Unfortunatly this do no allow to have an HTTP(S) PROXY set.

This #333 solution do not work because the new_client_from_config_dict is not using the _default object in kube_client.Configuration

What you expected to happen:
Been able to set a proxy variable or inject a client configuration when using the function new_client_from_config_dict

How to reproduce it (as minimally and precisely as possible):

# This is working
config.load_kube_config()
client.Configuration._default.proxy = "MY_HTTP_PROXY"
client.CoreV1Api().list_namespace()
# Impossible to set a proxy with a new client from config
my_client = config.new_client_from_config_dict(kubeconfig2)
my_client.configuration.proxy = "MY_HTTP_PROXY"
client.CoreV1Api(api_client=my_client).list_namespace()
# >> Proxy error

Environment:

  • Kubernetes version (kubectl version):
  • 1.23.8

  • OS (e.g., MacOS 10.13.6):
  • MacOS 13.0.1

  • Python version (python --version)
  • 3.9.13

  • Python client version (pip list | grep kubernetes)
  • 25.3.0

Thanks,

@FlorianJDF FlorianJDF added the kind/bug Categorizes issue or PR as related to a bug. label Dec 12, 2022
@roycaihw
Copy link
Member

/assign @FlorianJDF

@FlorianJDF
Copy link
Contributor Author

Hello all,
Do you have any news or any other patch than mine?
This issue is blocking using standard function when behind a proxy,

Cheers

@hilmeeen
Copy link

hilmeeen commented Apr 11, 2023

I got the same issue with new_client_from_config()

# Impossible to set a proxy with a new client from config
my_api_client=config.new_client_from_config(my_kubeconfig_file)
my_api_client.configuration.proxy="MY_HTTP_PROXY"
eks_client = dynamic.DynamicClient(my_api_client)
api_deployment = eks_client.resources.get(api_version="apps/v1", kind="Deployment")
api_deployment.get(namespace='MY_NAMESPACE',name='MY_DEPLOYMENT')
# >> Proxy error

@FlorianJDF
Copy link
Contributor Author

@hilmeeen you can use this fix if you want: #1968
Just waiting for my PR to be reviewed

@mkemmerz
Copy link

Any update on this?

@k8s-triage-robot
Copy link

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

This bot triages un-triaged issues 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 issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue 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 Jan 27, 2024
@kwibus
Copy link

kwibus commented Jan 28, 2024

you could try this solution.

config.load_kube_config()
k8s_config = client.Configuration().get_default_copy()
k8s_config .proxy = "MY_HTTP_PROXY"
client.Configuration().set_default(k8s_config) 
client.CoreV1Api().list_namespace()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
7 participants