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

2

20

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
  }
]
Wilma answered 9/1, 2018 at 7:36 Comment(0)
T
17
  • 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, e.g. 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 e.g. nginx, haproxy>:<servicePort> -> <mesos agent on which container runs>:<hostPort> -> <container>:<containerPort>

Technicality answered 9/1, 2018 at 9:41 Comment(2)
the heck is a targetPort then?Danadanae
@the0ther TargetPort is the port on the actual pod that requests are sent to.Turnsole
A
0

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.

Apocarp answered 14/2, 2019 at 13:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.