如何在kubernetes集群中SSH到docker容器?

问题描述:

我对Google Cloud平台和Docker还是相当陌生,并建立了一个节点集群,制作了一个Dockerfile,该文件可复制存储库并在公共端口上运行Clojure REPL.我可以从IDE连接到它,然后播放我的代码,真棒!

I am fairly new to the Google Cloud platform and Docker and set-up a cluster of nodes, made a Dockerfile that copies a repo and runs a Clojure REPL on a public port. I can connect to it from my IDE and play around with my code, awesome!

该REPL应该可能通过SSH隧道传输,但这是我的问题开始的地方. 我找不到合适的SSH地址,以更改Docker在其上运行REPL的存储库:

That REPL should however probably tunneled through SSH, but here is where my problem starts. I can't find a suitable place to SSH into for making changes to the repo that Docker runs the REPL on:

  • 公开的IP仅公开了REPL服务(正确的kubernetes术语?),并且不允许我进行SSH接入.
  • 集群主端点也没有,即使我遵循Adding or removing SSH keys for all of the instances in your project部分
  • The exposed IP just exposes the REPL service (correct kubernetes term?) and does not allow me to SSH in.
  • Neither does the cluster master endpoint, it gives me a public key error even though I've followed the Adding or removing SSH keys for all of the instances in your project part here.

我想通过SSH编辑源文件,但是我需要访问docker代码库.我不知道该怎么办.

I would like to edit the source files via SSH but I would need to access the docker code repo. I don't know how to proceed.

我了解这并不是部署应用程序的典型方法,因此我什至不确定是否有可能使多个节点与修改后的docker代码库一起工作(这些节点是否以某种方式共享JVM?).

I understand this isn't exactly a typical way to deploy applications so I am not even sure it's possible to have multiple nodes work with a modified docker codebase (do the nodes share the JVM somehow?).

具体地,我的问题是我如何通过SSH进入docker容器来访问代码库?

Concretely my question is how do I SSH into the docker container to access the codebase?

我找不到合适的SSH位置来更改Docker在其上运行REPL的存储库

I can't find a suitable place to SSH into for making changes to the repo that Docker runs the REPL on

创建集群时,您在Google云端项目中配置了许多节点VM.如果您查看 https://console.cloud.google.com/compute/instances 您应该会看到它们,并且每个人都有一个外部IP地址,您可以将其插入.然后创建到节点VM的ssh隧道,该节点将本地端口转发到Pod IP地址.

When you create a cluster, you provision a number of node VMs in your google cloud project. If you look at https://console.cloud.google.com/compute/instances you should see them and each one will have a External IP address which you will be able to ssh into. Then create an ssh tunnel to a node VM that forwards a local port to the pod IP address.

请注意,如果您正在运行clojure应用程序的多个副本,则必须分别连接到每个副本才能更新该应用程序.

Note that if you are running multiple replicas of your clojure app, you must connect to each replica separately to update the app.