kubectl exec into pod resulting in Unable to use a TTY error every time if run through automation

。_饼干妹妹 提交于 2020-05-17 09:24:32

问题


i have a simple automation to exec into a kubernetes pod but it always results in the below error :-

kubectl exec -it my-pod -c my-contaner -n my-namespace /bin/bash
Unable to use a TTY - input is not a terminal or the right kind of file

I am trying to run a simple shell script using jenkins to exec into a pod and execute ls -las in the root directory but its not allowing to exec into the pod automatically. The same thing works fine if i do manually on the linux server terminal. Can someone help fix this issue


回答1:


I got same error while creating a pod during Jenkins build:

$ oc run netshoot-pod --attach=true --restart=Never --rm -i --tty --image nicolaka/netshoot -- curl $IP

Unable to use a TTY - input is not a terminal or the right kind of file 
If you don't see a command prompt, try pressing enter. 
Error attaching, falling back to logs

Removing --tty / -t flag has fixed it.




回答2:


I got it working using the below approach :-

kubectl exec -ti my-pod -c my-container -n my-namespace -- ls


来源:https://stackoverflow.com/questions/59002583/kubectl-exec-into-pod-resulting-in-unable-to-use-a-tty-error-every-time-if-run-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!