SSL connection failed to HTTPS K8S cluster
Hello,
I'm on Windows, using Python 2.7.4. I'm trying to reach a Kubernetes cluster behind a corporate proxy, bypassed by cntlm. I set HTTP_PROXY and HTTPS_PROXY variables to http;//localhost:3128 pointing at my cntlm.
I get a connection failed when trying to perform simple request through kubernetes Python client:
WARNING Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xff5c6f2c>: Failed to establish a new connection: [Errno 116] Connection timed out',)': /api/v1/pods?watch=False
Here is my small code :
import sys
import os
import getpass
import requests
import apitoken
import urllib3
from kubernetes import config
from kubernetes.client import configuration
from kubernetes.client.apis import core_v1_api
from kubernetes.client.rest import ApiException
def InitOCLogin():
config.load_kube_config(".kubeconfig")
configuration.assert_hostname = False
api = core_v1_api.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces()
for i in ret.items:
print("%s\t%s\t%s" %
(i.status.pod_ip, i.metadata.namespace, i.metadata.name))
def main():
InitOCLogin()
if __name__ == "__main__":
main()
I struggle to find how to connect through this client... When using curl with -k, i managed to fetch the K8S API.
Could you help me to figure out what's wrong?
are HTTP_PROXY and HTTPS_PROXY environment variables? I don't think we support them but we have configuration.http_proxy that you can use if you are using the latest release of the client. I would be nice to support those environment variables in the client if you are up for it :) Let me know if setting configuration.http_proxy fixed your issue.
Yes, they are environment variables. I tried the configuration.http_proxy but it doesn't seem to change anything. I think i already manage to get past the proxy but the error is then on the insecure certificate issued by the cluster. With curl i can bypass the verification with the -k flag but with Kubernetes Python Client i cannot pass parameters to urllib3.
urllib3.connection.VerifiedHTTPSConnection is the core of the problem.
For example, with requests, i can do requests.get(myurl, headers=head, verify=False) to make it works.
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
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
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
@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.
@lainra did you ever figure out how to get around this? I am having the same problem.