Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Nodes cannot access pod's local PortMappings #1863

Closed
daschott opened this issue Mar 21, 2023 · 4 comments · Fixed by #1922
Closed

Windows Nodes cannot access pod's local PortMappings #1863

daschott opened this issue Mar 21, 2023 · 4 comments · Fixed by #1922
Assignees
Labels
cni Related to CNI.

Comments

@daschott
Copy link

daschott commented Mar 21, 2023

What happened:
When node attempts to access its own local hostPort mapped to pod, traffic will never reach container networking stack but instead be dropped by TCP/IP stack.

What you expected to happen:
I would expect traffic to be routed from TCP/IP stack to container networking stack. To achieve this, we need to substitute the hcsshim.NatPolicy

This should be switched from V1 HNS to V2 HCN API and set LocalRoutedVIP flag. This will instrument the OS to add a route to the host which will make this traffic reach vSwitch.

Here is some sample code to replace the hcsshim.NatPolicy:

	natPolicy := hcn.PortMappingPolicySetting{
		InternalPort: portMappingPolicy.InternalPort,
		ExternalPort: portMappingPolicy.ExternalPort,
		Flags:        hcn.NatFlags(hcn.NatFlagsLocalRoutedVip),
	}
	switch portMappingPolicy.Protocol {
	case ProtocolTcp:
		natPolicy.Protocol = "TCP"
	case ProtocolUdp:
		natPolicy.Protocol = "UDP"
	}

How to reproduce it:

  1. Deploy a Windows Node without NodePort service pods running on the node.
  2. Deploy a pod with hostPort mapping.
  3. From the Node, curl node_ip:hostPort
  4. Observe traffic will be dropped by TCP/IP

Orchestrator and Version (e.g. Kubernetes, Docker):
Kubernetes

Operating System (Linux/Windows):
Windows Server 2022 + Windows Server 2019

Kernel (e.g. uanme -a for Linux or $(Get-ItemProperty -Path "C:\windows\system32\hal.dll").VersionInfo.FileVersion for Windows):

Anything else we need to know?:
[Miscellaneous information that will assist in solving the issue.]

@rbtr rbtr added the cni Related to CNI. label Mar 21, 2023
@AbelHu
Copy link
Member

AbelHu commented Mar 22, 2023

@daschott what is the workaround if user hit this issue?

@daschott
Copy link
Author

As a workaround, users can schedule a pod with NodePort service. HNS will then also add the same route.

@tamilmani1989
Copy link
Member

will sync with @daschott on this today

@Sul55

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cni Related to CNI.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants