简体   繁体   中英

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

I am confused with what all these port signify container port,host port and service port in portMappings, below is my json

"portMappings": [
  {
    "containerPort": 9000,
    "hostPort": 9000,
    "labels": {
      "VIP_0": "/app2n:9000"
    },
    "protocol": "tcp",
    "servicePort": 10101
  }
]
  • containerPort is the port in the container, one which your containerized app should listen on,
  • hostPort is the port which will be visible on the Mesos Agent where container is running,
  • servicePort is abstract port for internal use of framework, eg it can be used in loadbalancer as port mapped to host on which your run your container and its hostPort . Should be unique across your cluster.

Basically flow looks like this: internet -> <loadbalancer eg nginx, haproxy>:<servicePort> -> <mesos agent on which container runs>:<hostPort> -> <container>:<containerPort>

A targetPort This is the port on the pod that the request gets sent to. Your application needs to be listening for network requests on this port for the service to work. These ports are typically used in service yaml descriptors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM