如何通过 ssh 进入 Traefik pod?

How to ssh into a Traefik pod?

我正在使用 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' 也是一样。

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

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'

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

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