hostPort forwards a port on the hosting node to a port in a container while the pod keeps its own network. The container listens on its container port; Kubernetes makes that process reachable through the selected host port. section 17.3.1
Use hostPort when a client needs to reach the daemon pod local to a particular node.
- A request to a node's host port reaches only the agent pod on that same node. section 17.3.1
- If no matching daemon pod runs on the node, connecting to that host port fails. section 17.3.1
- Unlike a NodePort Service, hostPort does not forward to a random pod elsewhere in the cluster. section 17.3.1
- A daemon pod can instead use hostNetwork, but that gives it the node's network environment and no separate pod IP; hostPort preserves the pod's own network. section 17.2.3 section 17.4
Forwarding port 11559 to a node agent
A DaemonSet can configure its node-agent container to listen on port 80 and expose that port through host port 11559. After the pods run on the nodes, request a node's address at port 11559, such as `curl 172.18.0.2:11559`. The response comes from the agent on that node. If a firewall blocks the address, access the node and request `curl localhost:11559`.
