portMappings中dcosjson中容器端口、主机端口、服务端口的区别

Difference between container port,host port and service port in dcos json in portMappings

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

"portMappings": [
  {
    "containerPort": 9000,
    "hostPort": 9000,
    "labels": {
      "VIP_0": "/app2n:9000"
    },
    "protocol": "tcp",
    "servicePort": 10101
  }
]
  • containerPort 是容器中的端口,您的容器化应用程序应该监听的端口,
  • hostPort 是 Mesos Agent 上可见的端口,其中容器是 运行ning,
  • servicePort 是框架内部使用的抽象端口,例如它可以在负载均衡器中用作端口映射到您的 运行 您的容器及其 ​​hostPort 的主机。在您的集群中应该是唯一的。

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

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