【问题标题】:Difference between container port,host port and service port in dcos json in portMappingsportMappings中dcos json中容器端口、主机端口和服务端口的区别
【发布时间】:2018-01-09 07:36:30
【问题描述】:

我对所有这些端口在 portMappings 中表示容器端口、主机端口和服务端口的含义感到困惑,下面是我的 json

"portMappings": [
  {
    "containerPort": 9000,
    "hostPort": 9000,
    "labels": {
      "VIP_0": "/app2n:9000"
    },
    "protocol": "tcp",
    "servicePort": 10101
  }
]

【问题讨论】:

    标签: docker containers dcos


    【解决方案1】:
    • containerPort 是容器中的端口,您的容器化应用应该监听的端口,
    • hostPort 是在运行容器的 Mesos 代理上可见的端口,
    • servicePort 是框架内部使用的抽象端口,例如它可以在负载均衡器中用作映射到运行容器及其hostPort 的主机的端口。在整个集群中应该是唯一的。

    流程基本上是这样的: 互联网 -> <loadbalancer e.g. nginx, haproxy>:<servicePort> -> <mesos agent on which container runs>:<hostPort> -> <container>:<containerPort>

    【讨论】:

    • 那么到底是targetPort
    • @the0ther TargetPort 是请求发送到的实际 pod 上的端口。
    【解决方案2】:

    A targetPort 这是请求被发送到的 pod 上的端口。您的应用程序需要在此端口上侦听网络请求才能使服务正常工作。这些端口通常用于服务 yaml 描述符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-06
      • 1970-01-01
      • 2020-02-29
      • 1970-01-01
      • 1970-01-01
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多