【问题标题】:How to ssh into a Traefik pod?如何通过 ssh 进入 Traefik pod?
【发布时间】:2019-03-12 05:58:50
【问题描述】:

我正在使用 GKE。我已经通过 kubectl 启动了以下 traefik 部署:

https://github.com/containous/traefik/blob/master/examples/k8s/traefik-deployment.yaml

pod 在 kube-system 命名空间上运行。 我无法通过 ssh 进入 pod。

kubectl get po -n kube-system traefik-ingress-controller-5bf599f65d-fl9gx 1/1 Running 0 30m

kubectl exec -it traefik-ingress-controller-5bf599f65d-fl9gx -n kube-system -- '\bin\bash' rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"\\\\bin\\\\bash\": executable file not found in $PATH" command terminated with exit code 126

我错过了什么吗? '--sh' 也一样。

【问题讨论】:

    标签: kubernetes google-kubernetes-engine traefik


    【解决方案1】:

    而是使用正斜杠/(您的示例有一个反斜杠),例如在

    kubectl exec -it traefik-ingress-controller-5bf599f65d-fl9gx -n kube-system -- '/bin/bash'
    

    如果这仍然不起作用,请尝试其他 shell,例如

    kubectl exec -it traefik-ingress-controller-5bf599f65d-fl9gx -n kube-system -- '/bin/sh'
    

    【讨论】:

    • 是的。 kubectl exec -it traefik-ingress-controller-7fc5d6f569-tlr4t -n kube-system -- '/bin/sh' rpc 错误:代码 = 2 desc = oci 运行时错误:执行失败:container_linux.go:247:启动容器进程导致 "exec: \"/bin/sh\": stat /bin/sh: no such file or directory" 命令以退出代码 126 终止
    • 你找到任何带有-- 'ls /bin/'的shell吗?
    • 我收到以下错误:rpc 错误:code = 2 desc = oci 运行时错误:exec 失败:container_linux.go:247:启动容器进程导致“exec:\”ls /bin/\” : stat ls /bin/: 没有这样的文件或目录"
    • 对不起,我不知道这个局部图像。是否有任何基于 alpine linux 的图像?至少-- 'ls /' 有输出吗?
    • 没有。甚至 -- 'ls /' 什么都不做。即使我以前尝试过所有这些,也找不到任何解决方案。我很可能错过了一些微不足道的东西。没有把握。感谢您的帮助。
    【解决方案2】:

    所以,显然默认的 traefik 图像是 amd64 版本。我必须使用 alpine 版本通过 ssh 进入它: kubectl exec -it _podname_ -- sh

    【讨论】:

    • 尝试了这个解决方案,但没有成功。我们收到以下错误 - “OCI 运行时执行失败:执行失败:container_linux.go:345:启动容器进程导致“exec:\”sh \": $PATH 中找不到可执行文件": 未知命令以退出代码 126 终止
    【解决方案3】:

    看来this here 是正确答案。您不能使用默认映像将 shell 执行到 traefik 容器中,您必须使用 alpine 之一。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-31
      • 2016-05-25
      • 1970-01-01
      • 2015-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多