Description
Python : get error "Upgrade request required" for exec command using exec with connect_get_namespaced_pod_exec
when I create the pod with python api I can use kubectl and run the following commands successfully at linux command line:
kubectl exec secret-pod --namespace=production cat data/busybox/username
and
kubectl exec secret-pod --namespace=production cat data/busybox/password
The following python code fails with "Upgrade request required"
def _get_user_token(self):
try:
user = self.core_api_instance.connect_get_namespaced_pod_exec(name="secret-pod",
namespace="production",
command=["cat /data/busybox/username"],
stderr=True, stdin=False,
stdout=True, tty=False)
pprint(user)
except ApiException as e:
print("Exception when calling CoreV1Api->get_namespaced_pod_exec: %s\n" % e)
exec_cmd = ['cat /data/busybox/password']
try:
passwd = self.core_api_instance.connect_get_namespaced_pod_exec(name="secret-pod",
namespace='production',
command=["cat /data/busybox/password"],
stderr=True, stdin=False,
stdout=True, tty=False)
pprint(passwd)
except ApiException as e:
print("Exception when calling CoreV1Api->get_namespaced_pod_exec: %s\n" % e)
return {'user': user, 'password': passwd}