terratest
terratest copied to clipboard
kubectl run with stdin not working in k8s.RunKubectl method
This is my code below :
output2, _ := k8s.RunKubectlAndGetOutputE(t, kubectlOptions, "run", "netshoot", "--generator=run-pod/v1", "--image=nicolaka/netshoot", "-i", "--", podCommand)
And the output of that command here is :
command.go:87: Running command kubectl with args [run netshoot --generator=run-pod/v1 --image=nicolaka/netshoot -i -- curl http://172.17.0.5:8200/v1]
but after that nothing happens and process stucks here.
I believe you also need the -t
flag, but in general I believe interactive commands don't quite work when going through terratest
because of the way the logging infrastructure works.
I believe you also need the
-t
flag, but in general I believe interactive commands don't quite work when going throughterratest
because of the way the logging infrastructure works.
I added -t flag also, but nothing changed @yorinasub17
Running command kubectl with args [run netshoot --generator=run-pod/v1 -it --image=nicolaka/netshoot curl http://172.17.0.5:8200/v1]
Hi, not sure if the issue is still actual, I tested this code, and got results from curl execution:
curlOutput, _ := k8s.RunKubectlAndGetOutputE(t, options, "run", "netshoot", "--image=nicolaka/netshoot", "-i", "--", "curl", "google.com")
fmt.Printf("\n%s\n", curlOutput)
Output:
TestKubernetesRun 2022-01-09T20:50:19+02:00 logger.go:66: Running command kubectl with args [--namespace default run netshoot --image=nicolaka/netshoot -i -- curl google.com]
TestKubernetesRun 2022-01-09T20:51:12+02:00 logger.go:66: If you don't see a command prompt, try pressing enter.
TestKubernetesRun 2022-01-09T20:51:12+02:00 logger.go:66: <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
TestKubernetesRun 2022-01-09T20:51:12+02:00 logger.go:66: <TITLE>301 Moved</TITLE></HEAD><BODY>
TestKubernetesRun 2022-01-09T20:51:12+02:00 logger.go:66: <H1>301 Moved</H1>
TestKubernetesRun 2022-01-09T20:51:12+02:00 logger.go:66: The document has moved
TestKubernetesRun 2022-01-09T20:51:12+02:00 logger.go:66: <A HREF="http://www.google.com/">here</A>.
TestKubernetesRun 2022-01-09T20:51:12+02:00 logger.go:66: </BODY></HTML>