-
Notifications
You must be signed in to change notification settings - Fork 241
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
fix: [CNI] NAT hostPort mapping for HNSv2 #1922
Conversation
cni/network/network_windows.go
Outdated
@@ -257,6 +257,7 @@ func getPoliciesFromRuntimeCfg(nwCfg *cni.NetworkConfig) []policy.Policy { | |||
InternalPort: uint16(mapping.ContainerPort), | |||
VIP: mapping.HostIp, | |||
Protocol: protocol, | |||
Flags: hnsv2.NatFlagsLocalRoutedVip, // iota'd, NatFlagsLocalRoutedVip = 1, uint32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a constant value ? What does this mean ? ( Just curious)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a constant value set here https://github.com/microsoft/hcsshim/blob/298b31d151ab799c1d7686f8ee9eec1cb4213926/hcn/hcnpolicy.go#L82 .
Was trying to match other code snippets in cni where they match the TCP/UDP to constant values as well.
I could remove the iota'd comment and change it to // uint32 NatFlagsLocalRoutedVip = 1
if that makes it more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment above this change saying "its to support hostport policy mapping"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* NAT update * NAT update * Cleaning up and unit test * Fix Lint * Fix Lint * Fix Lint - Addr. comments --------- Co-authored-by: jpayne3506 <[email protected]>
* NAT update * NAT update * Cleaning up and unit test * Fix Lint * Fix Lint * Fix Lint - Addr. comments --------- Co-authored-by: jpayne3506 <[email protected]>
Reason for Change:
Enables the use of hostport mapping with HNSv2 by setting a flag in PortMappingPolicySetting. This reflects in hnsendpoint by showing a new policy for the route which is created by the OS.
Issue Fixed:
Fixes #1863
Requirements:
Notes:
You can confirm the policy and route through the node by using
get-hnsendpoint | ? IPAddress -Like "node ip" | Convertto-json -d 16
for exclusively policy use
get-hnsendpoint | ? IPAddress -Like "node ip" | Select Policies | Convertto-json -d 16
Internal port / containerPort must match an already listening port on the pod. If not using the default service port 80, user will need to create and open port.