<p>I am following the <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CoreV1Api.md#connect_get_namespaced_pod_exec" rel="nofollow noreferrer">official documentation</a> and to my surprise, the request just won't work.</p>

<p>I tried reading multiple questions and answers but in vain. I had set <code>stream</code> api to use but the error did not go away.</p>

<p>My code is:</p>

<pre><code>from __future__ import print_function
import time
import kubernetes.client
from kubernetes.client.rest import ApiException
from pprint import pprint
from kubernetes import client, config, stream
stream = stream.stream

# Configure API key authorization: BearerToken
configuration = kubernetes.client.Configuration()
configuration.host = "https://my_aws_server.amazonaws.com"
configuration.verify_ssl = False
configuration.api_key['authorization'] = "some_token"
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
configuration.api_key_prefix['authorization'] = 'Bearer'
configuration.debug = True

api_instance = kubernetes.client.CoreV1Api(
    kubernetes.client.ApiClient(configuration))
name = 'jupyter-ankita'  # str | name of the PodExecOptions
namespace = 'jhub'  # str | object name and auth scope, such as for teams and projects
# str | Command is the remote command to execute. argv array. Not executed within a shell. (optional)
command = 'echo "hail aviral"'
# bool | Redirect the standard error stream of the pod for this call. Defaults to true. (optional)
stderr = True
# bool | Redirect the standard input stream of the pod for this call. Defaults to false. (optional)
stdin = True
# bool | Redirect the standard output stream of the pod for this call. Defaults to true. (optional)
stdout = True
# bool | TTY if true indicates that a tty will be allocated for the exec call. Defaults to false. (optional)
tty = True

try:
    api_response = stream(api_instance.connect_post_namespaced_pod_exec(
        name, namespace, command=command, stderr=stderr, stdin=stdin, stdout=stdout)
    )
    pprint(api_response)
except ApiException as e:
    print("Exception when calling CoreV1Api-&gt;connect_post_namespaced_pod_exec: %s\n" % e)

</code></pre>

<p>I want the command to run but instead, I am facing an error:</p>

<pre><code>Exception when calling CoreV1Api-&gt;connect_post_namespaced_pod_exec: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Audit-Id': '88df8863-61b1-4fe7-9d39-d0e6059ea993', 'Content-Type': 'application/json', 'Date': 'Tue, 28 May 2019 14:04:38 GMT', 'Content-Length': '139'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Upgrade request required","reason":"BadRequest","code":400}
</code></pre>

<p>My SSL client is updated, I am using Python3.7 from the <code>brew</code> on a MacOS.</p>

<p>Also used on Ubuntu, same error.</p>

<p>The versions are:</p>

<pre><code>Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.3", GitCommit:"some_no", GitTreeState:"clean", BuildDate:"2018-11-27T01:14:37Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"12+", GitVersion:"v1.12.6-eks-d69f1b", GitCommit:"some_no", GitTreeState:"clean", BuildDate:"2019-02-28T20:26:10Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<ul>
<li>UPDATE:
I changed my functions to:</li>
</ul>

<pre><code>api_response = stream( api_instance.connect_post_namespaced_pod_exec, name, namespace, command=command, stderr=stderr, stdin=stdin, stdout=stdout )
</code></pre>

<p>and it was able to exec. But, now I am facing the following error:</p>

<pre><code>('rpc error: code = 2 desc = oci runtime error: exec failed: '
 'container_linux.go:262: starting container process caused "exec: \\"echo '
 '\\\\\\"hail aviral\\\\\\"\\": executable file not found in $PATH"\n'
 '\r\n')
</code></pre>

<p>It is saying that the <code>exec</code> failed.</p>

<p>Missing entry point for the remote command execution.
Try this one:</p>

<pre><code>command = [
    '/bin/sh',
    '-c',
    'echo hail aviral']
</code></pre>
