在Google Container Engine中公开两个端口 [英] Exposing two ports in Google Container Engine

查看:51
本文介绍了在Google Container Engine中公开两个端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在暴露两个端口的Google容器引擎中创建Pod:端口8080正在侦听传入的内容,端口80将该内容分发给客户端?

Is it possible to create a Pod in the Google Container Engine where two ports are exposed: port 8080 is listening for incoming content and port 80 distributes this content to clients?

Google提供了以下创建Pod的命令作为示例:

The following command to create a Pod is given as example by Google:

kubectl run hello-node --image=gcr.io/${PROJECT_ID}/hello-node --port=8080

我似乎无法定义侦听端口,并且在添加第二个"--port ="开关时,仅暴露了一个端口. 有没有办法暴露第二个端口,或者每个容器只能限制一个端口?

I can't seem to define a listening port, and when adding a second "--port=" switch only one port is exposed. Is there a way to expose a second port or am I limited to one port per container?

推荐答案

否,您不能在kubectl run中指定多个端口.但是您可以使用kubectl create创建复制控制器,并为容器指定多个端口.

No, you cannot specify multiple ports in kubectl run. But you can use kubectl create to create a replication controller, and specify multiple ports for the container.

https://github.com/kubernetes/examples/blob/master/cassandra/cassandra-statefulset.yaml 有一个示例:

          ports:
        - containerPort: 7000
          name: intra-node
        - containerPort: 7001
          name: tls-intra-node
        - containerPort: 7199
          name: jmx
        - containerPort: 9042
          name: cql

这篇关于在Google Container Engine中公开两个端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆