3

I am trying to connect to a Docker container on Google Container Engine(GKE) from my local machine through the internet by TCP protocol. So far I have used Kubernetes services which gives an external IP address, so the local machine can connect to the container on GKE using the service. When we create a service, we can specify only one port and cannot specify the port range. Please see the my-ros-service.yaml below. In this case, we can access the container by 11311 port from outside of GCE.

However, some applications that run on my container expose dynamic ports to connect to other applications. Therefore I cannot determine the port number that the application uses and cannot create the Kubernetes services before I run the application.

So far I have managed to connect to the container by creating many services which have different port while running the application. But this is not a realistic way to solve the problem.

My question is that:

How to connect to the application that exposes dynamic ports on Docker container from outside of the GCE by using Kubernetes service?

If possible, can we create a service which exposes dynamic port for incoming connection before running the application which runs on the container?

Any advice or information you could provide would be greatly appreciated.

Thank you in advance.

my-ros-service.yaml

kind: Service
apiVersion: v1beta1
id: my-ros-service
port: 11311
selector:
  name: my-ros
containerPort: 11311
createExternalLoadBalancer: true
4

1 回答 1

6

我认为目前没有比您正在做的更好的解决方案。已经有一个相关的问题,kubernetes issue 1802,关于每个服务有多个端口。我提到了你对这个问题的要求。您可能想要跟进有关您的用例的更多信息,例如您正在运行的程序(如果它是公开可用的),以及动态端口是否来自特定的连续范围。

于 2014-12-22T15:56:44.340 回答