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

Connection Refused when using client behind coporate proxy to connect to AWS Cluster #549

Closed
jueast08 opened this issue Jun 18, 2018 · 9 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@jueast08
Copy link

So I've been using the client for about a week, and I have to say I love it and what it can do. However, I've noticed that when using the client at work I receive the following errors despite the fact that all kubectl commands work :

2018-06-18 11:20:15,250 WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff4dc6f69d0>: Failed to establish a new connection: [Errno 111] Connection refused',)': /api/v1/namespaces/default/status 2018-06-18 11:20:15,254 WARNING Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff4dc6f6910>: Failed to establish a new connection: [Errno 111] Connection refused',)': /api/v1/namespaces/default/status 2018-06-18 11:20:15,258 WARNING Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff4dc6f6a90>: Failed to establish a new connection: [Errno 111] Connection refused',)': /api/v1/namespaces/default/status HTTPSConnectionPool(host='<ip_address>', port=443): Max retries exceeded with url: /api/v1/namespaces/default/status (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff4dc6f6a10>: Failed to establish a new connection: [Errno 111] Connection refused',))

I've tried using the default config.load_kube_config() function. I've also tried to set the proxy using :
conf = client.Configuration() conf.http_proxy_url = <proxy> config.load_kube_config(client_configuration=conf)
The latter command fixes the host as 'localhost' rather than the IP of my AWS cluster

@tomplus
Copy link
Member

tomplus commented Jun 18, 2018

Can you show us your kubeconfig file ~/.kube/config (with removed certs/passwords/ips if it's neccessary) ? It's interesting that kubectl works and this library try to connect but the connection is refused.

@jueast08
Copy link
Author

jueast08 commented Jun 18, 2018

Weirdly enough, I went into the source code of the ApiClient to see if I could kick start the thing and gain more info about what the problem may be.

I was able to make the client work behind my proxy by doing the following in the init function of the api_client.py module:

def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None): if configuration is None: configuration = Configuration() configuration.proxy = <proxy_url> # <---- I added my proxy url here to see if there would be a change in the result self.configuration = configuration ...

edit : The copy of the code looks pretty bad, but I just added to line 65 of the file api_client.py :
configuration.proxy = <proxy>

Setting the proxy via the specified methods or launching my code in an environment with the correctly proxy variables set had no effect, where as this "fixed" the problem immediately

@jueast08
Copy link
Author

Ok. So I ended up doing the following (this time without editing the sources)

config.load_kube_config()
conf = client.Configuration()
conf.proxy = <my_proxy>
client.Configuration.set_default(conf)

Not sure if it was indicated in the docs to do a load_kube_config() and use that to solve the proxy issue, but I could not see anything of the kind

@abushoeb
Copy link

Check this #333 (comment)

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/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 24, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/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 24, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

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.

@Omegastick
Copy link

Ok. So I ended up doing the following (this time without editing the sources)

config.load_kube_config()
conf = client.Configuration()
conf.proxy = <my_proxy>
client.Configuration.set_default(conf)

Not sure if it was indicated in the docs to do a load_kube_config() and use that to solve the proxy issue, but I could not see anything of the kind

This doesn't work for me. Only changing the ApiClient source as described in the previous comment does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

6 participants