Packet flow for connection from the host stack to Service
May 31, 2018 ยท View on GitHub
Request
For request sent from the host with the source address hostIP:hostPort
destined to service serviceIP:servicePort, load-balanced to the endpoint
serverIP:serverPort running inside pod on the same node:
- Connections initiated from the host stack of cluster nodes and destined
to services are captured and proxied by iptable rules installed by Kube-proxy.
The rules will randomly select one of the service endpoints and establish
proxying for the connection.
Request originally sent to
serviceIP:servicePortwill arrive to VPP viatap0already proxied to a chosenserverIP:serverPort. - The redirected request is sent to the server via the same path as for directly accessed pods from the host. In fact, from the VPP point of view the two scenarios are indistinguishable (i.e. equivalent packet traces).
Response
For response sent from server serverIP:serverPort, acting as an endpoint for
service serviceIP:servicePort, back to the client in the host stack
hostIP:hostPort on the same node:
- Steps 1.-5. listed for the response in the Host to Pod scenario are taken to deliver the response into the host stack. In fact, from the VPP point of view the two scenarios are indistinguishable (i.e. equivalent packet traces).
- In the host-stack, the transparent proxy configured by kube-proxy matches
a dynamic entry created for the connection and translates the source address
serverIP:serverPortback to service VIPserviceIP:servicePort
Diagram
