Running `connect_get_namespaced_pod_exec` using kubernetes client corev1api gives bad request
I wrote a simple program to check that:
from kubernetes import client, configfrom kubernetes.stream import stream# create an instance of the API classconfig.load_kube_config()api_instance = client.CoreV1Api()exec_command = [ '/bin/sh', '-c', 'echo This is Prafull Ladha and it is test function']resp = stream(api_instance.connect_get_namespaced_pod_exec, "nginx-deployment-76bf4969df-467z2", 'default', command=exec_command, stderr=True, stdin=False, stdout=True, tty=False)print("Response: " + resp)
It is working perfectly fine for me.
I believe you're using minikube
for development purpose. It is not able to recognise your hostname. You can make it work by disabling assert_hostname
in your program like:
from kubernetes.client import configuration config.load_kube_config() configuration.assert_hostname = False
This should resolve your issue.