【问题标题】:kubectl exec into pod resulting in Unable to use a TTY error every time if run through automation如果通过自动化运行,kubectl exec into pod 导致每次都无法使用 TTY 错误
【发布时间】:2019-11-22 22:29:10
【问题描述】:

我有一个简单的自动化来执行到 kubernetes pod 中,但它总是导致以下错误:-

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

我正在尝试使用 jenkins 运行一个简单的 shell 脚本来执行到一个 pod 并在根目录中执行 ls -las 但它不允许自动执行到 pod 中。如果我在 linux 服务器终端上手动操作,同样的事情也可以正常工作。 有人可以帮忙解决这个问题吗

【问题讨论】:

  • 如果这是自动化,你可能不想要-it
  • 感谢 coderanger 但是我如何从 pod 内执行命令,因为登录永远不会像看起来或看起来那样发生,即使它确实发生了,但那里没有会话。我正在寻找的只是执行到 pod 并在登录后执行 bla bla bla
  • 如果这是一个脚本,你可能会运行类似kubectl exec my-pod -c my-contaner -n my-namespace -- /bin/bash /myscript.sh
  • 啊,我只是在运行 kubectl exec -it my-pod -c my-contaner -n my-namespace /bin/bash && ls -las 并且永远不会与 pod/container 建立 shell 会话
  • 我的意思是它可以交互地工作,但你不能从脚本中做到这一点。无论您正在做什么,您都需要真正实现自动化。

标签: shell jenkins kubernetes kubectl kubernetes-pod


【解决方案1】:

我在 Jenkins 构建期间创建 pod 时遇到了同样的错误:

$ 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

删除 --tty / -t 标志已修复。

【讨论】:

    【解决方案2】:

    我使用以下方法让它工作:-

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

    【讨论】:

      猜你喜欢
      • 2018-12-11
      • 2020-10-24
      • 1970-01-01
      • 2023-03-10
      • 2022-12-16
      • 2012-07-12
      • 2021-12-07
      • 1970-01-01
      • 2022-11-01
      相关资源
      最近更新 更多