<p><strong>Scenario:</strong></p>

<p>I'm trying to run a basic <code>ls</code> command using <code>kubernetes</code> package via <code>cli.connect_post_namespaced_pod_exec()</code> however I get a stacktrace that I do not know how to debug. Yes I have tried searching around but I'm not really sure what the problem is as I'm using documentation example from <a href="https://github.com/kubernetes-incubator/client-python/blob/master/kubernetes/docs/CoreV1Api.md#connect_get_namespaced_pod_exec" rel="nofollow noreferrer">here</a></p>

<p><strong>OS:</strong></p>

<p>macOS Sierra 10.12.2</p>

<p><strong>Code:</strong></p>

<pre><code>#!/usr/local/bin/python2.7

import logging

from pprint import pprint
from kubernetes import client, config

FORMAT = "[%(filename)s:%(lineno)s - %(funcName)s() ] %(message)s"
level = logging.DEBUG
logging.basicConfig(format=FORMAT, level=level)

def main():
    path_to_config = "/Users/acabrer/.kube/config"
    config.load_kube_config(config_file=path_to_config)
    ns = "default"
    pod = "nginx"
    cmd = "ls"
    cli = cli = client.CoreV1Api()
    response = cli.connect_post_namespaced_pod_exec(pod, ns, stderr=True, stdin=True, stdout=True, command=cmd)
    pprint(response)

if __name__ == '__main__':
    main()
</code></pre>

<p><strong>Stack Trace:</strong></p>

<pre><code>Traceback (most recent call last):
  File "/Users/acabrer/kube.py", line 16, in &lt;module&gt;
    main()
  File "/Users/acabrer/kube.py", line 12, in main
    response = cli.connect_post_namespaced_pod_exec(pod, ns, stderr=True, stdin=True, stdout=True)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 3605, in connect_post_namespaced_pod_exec
    (data) = self.connect_post_namespaced_pod_exec_with_http_info(name, namespace, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 3715, in connect_post_namespaced_pod_exec_with_http_info
    collection_formats=collection_formats)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 328, in call_api
    _return_http_data_only, collection_formats, _preload_content, _request_timeout)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 152, in __call_api
    _request_timeout=_request_timeout)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 373, in request
    body=body)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/rest.py", line 257, in POST
    body=body)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/rest.py", line 213, in request
    raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Sat, 21 Jan 2017 00:55:28 GMT', 'Content-Length': '139', 'Content-Type': 'application/json'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Upgrade request required","reason":"BadRequest","code":400}
</code></pre>

<p>Any input would be much appreaciated.</p>

<p><strong>Edit 1:</strong></p>

<pre><code>abrahams-mbp:.kube acabrer$ curl --help |grep TLSv
 -1, --tlsv1         Use &gt;= TLSv1 (SSL)
     --tlsv1.0       Use TLSv1.0 (SSL)
     --tlsv1.1       Use TLSv1.1 (SSL)
     --tlsv1.2       Use TLSv1.2 (SSL)
abrahams-mbp:.kube acabrer$ python2.7 -c "import ssl; print ssl.OPENSSL_VERSION_INFO"
(1, 0, 2, 10, 15)
</code></pre>

<p><strong>Edit 2:</strong></p>

<pre><code>abrahams-mbp:.kube acabrer$ curl --tlsv1.2 https://x.x.x.x -k
Unauthorized
abrahams-mbp:.kube acabrer$ curl --tlsv1.1 https://x.x.x.x -k
curl: (35) Unknown SSL protocol error in connection to x.x.x.x:-9836
</code></pre>

<p><strong>Edit 3:</strong>
I put some print statements to see the full on request information in <a href="https://github.com/kubernetes-incubator/client-python/blob/master/kubernetes/client/api_client.py#L341" rel="nofollow noreferrer">api_client.py</a> and this is what I see.</p>

<p><strong>Note:</strong> I removed the ip-address to my endpoint for security.</p>

<pre><code>bash-3.2# vim /usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py
bash-3.2# /Users/acabrer/kube.py
################
POST
https://x.x.x.x/api/v1/namespaces/default/pods/nginx/exec
[('stdin', True), ('command', 'ls'), ('stderr', True), ('stdout', True)]
{'Content-Type': 'application/json', 'Accept': '*/*', 'User-Agent': 'Swagger-Codegen/1.0.0-alpha/python'}
[]
None
################
</code></pre>

<p>Thanks,</p>

<p>-Abe.</p>

<p>To answer my own question here, this is a bug in actual python binding referenced here: <a href="https://github.com/kubernetes-incubator/client-python/issues/58" rel="nofollow noreferrer">https://github.com/kubernetes-incubator/client-python/issues/58</a></p>
