-
Notifications
You must be signed in to change notification settings - Fork 260
Enable outboundNAT for Windows containers. #86
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
Conversation
delete comment
… to test on a new cluster.
network/endpoint.go
Outdated
| log.Printf("[net] Created endpoint %+v.", ep) | ||
|
|
||
| return ep, nil | ||
|
|
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.
remove empty line
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.
done
network/endpoint_windows.go
Outdated
| if netNsPath != "" { | ||
| splits := strings.Split(netNsPath, ":") | ||
| if len(splits) == 2 { | ||
| epName = splits[1] |
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.
add comment here..briefly explaining two cases if and else?
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.
done
network/endpoint_windows.go
Outdated
| epName = containerID | ||
| } | ||
| if len(epName) > 8 { | ||
| epName = epName[:8] + "-" + ifName |
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.
Why are we choosing first 8 characters of ContainerID? Will the first 8 characters will be unique for all containers?
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.
We construct endpoint ID using first 8 characters of containerID and interface name. Please check plugin.go line 162-168.
network/endpoint_windows.go
Outdated
| // newEndpointImpl creates a new endpoint in the network. | ||
| func (nw *network) newEndpointImpl(epInfo *EndpointInfo) (*endpoint, error) { | ||
| // Ignore consecutive ADD calls for the same container. | ||
| if nw.Endpoints[epInfo.Id] != nil { |
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.
Which one you are using as a key in Endpoints map - epName or epinfo.Id ? In line 54, you are using epName as key for same map. Are both same?
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.
epinfo.Id is generated from containerID of ADD call. If the ADD call is for infrastructure container, then epName == epinfo.id. Basic, when I use epName as a key for nw.Endpoints, I am handling the ADD call for workload container. I want to return the endpoint for infrastructure container, since these two containers belong to the same pod. Reference: https://kubernetes.io/docs/concepts/cluster-administration/networking/#kubernetes-model
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.
Thank you got it. Checking GetHNSEndpointByName not nil solves object already exists issue. Can you please add some details in function description?
| } | ||
|
|
||
| //enable outbound NAT | ||
| var enableOutBoundNat = json.RawMessage(`{"Type": "OutBoundNAT"}`) |
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.
Do we have unit test for testing this function? If its there, can we add one to test this property is set?
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.
I didn't write unit test for this. We can discuss this.
| nw.Endpoints[epInfo.Id] = ep | ||
|
|
||
| log.Printf("[net] Created endpoint %+v.", ep) | ||
|
|
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.
remove this empty line also. not needed
tamilmani1989
left a comment
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.
looks good
What this PR does / why we need it:
Which issue this PR fixes