Unverified Commit bcb74bc2 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #66064 from honkiko/fix-nodeport-local

Automatic merge from submit-queue (batch tested with PRs 66064, 66040). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix Local externalTrafficPolicy is not respected for ipvs NodePort **What this PR does / why we need it**: Local externalTrafficPolicy is not respected for ipvs NodePort. This PR fixes it. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #66062 **Special notes for your reviewer**: Manually tested accessing NodePort with externalTrafficPolicy=Local and externalTrafficPolicy=Cluster. **Release note**: ```release-note ```
parents 337dfe0a 8bb6a5fa
...@@ -1116,7 +1116,7 @@ func (proxier *Proxier) syncProxyRules() { ...@@ -1116,7 +1116,7 @@ func (proxier *Proxier) syncProxyRules() {
// There is no need to bind Node IP to dummy interface, so set parameter `bindAddr` to `false`. // There is no need to bind Node IP to dummy interface, so set parameter `bindAddr` to `false`.
if err := proxier.syncService(svcNameString, serv, false); err == nil { if err := proxier.syncService(svcNameString, serv, false); err == nil {
activeIPVSServices[serv.String()] = true activeIPVSServices[serv.String()] = true
if err := proxier.syncEndpoint(svcName, false, serv); err != nil { if err := proxier.syncEndpoint(svcName, svcInfo.OnlyNodeLocalEndpoints, serv); err != nil {
glog.Errorf("Failed to sync endpoint for service: %v, err: %v", serv, err) glog.Errorf("Failed to sync endpoint for service: %v, err: %v", serv, err)
} }
} else { } else {
......
...@@ -1001,18 +1001,32 @@ func TestOnlyLocalNodePorts(t *testing.T) { ...@@ -1001,18 +1001,32 @@ func TestOnlyLocalNodePorts(t *testing.T) {
) )
epIP := "10.180.0.1" epIP := "10.180.0.1"
epIP1 := "10.180.1.1"
thisHostname := testHostname
otherHostname := "other-hostname"
makeEndpointsMap(fp, makeEndpointsMap(fp,
makeTestEndpoints(svcPortName.Namespace, svcPortName.Name, func(ept *api.Endpoints) { makeTestEndpoints(svcPortName.Namespace, svcPortName.Name, func(ept *api.Endpoints) {
ept.Subsets = []api.EndpointSubset{{ ept.Subsets = []api.EndpointSubset{
Addresses: []api.EndpointAddress{{ { // **local** endpoint address, should be added as RS
IP: epIP, Addresses: []api.EndpointAddress{{
NodeName: nil, IP: epIP,
}}, NodeName: &thisHostname,
Ports: []api.EndpointPort{{ }},
Name: svcPortName.Port, Ports: []api.EndpointPort{{
Port: int32(svcPort), Name: svcPortName.Port,
}}, Port: int32(svcPort),
}} }}},
{ // **remote** endpoint address, should not be added as RS
Addresses: []api.EndpointAddress{{
IP: epIP1,
NodeName: &otherHostname,
}},
Ports: []api.EndpointPort{{
Name: svcPortName.Port,
Port: int32(svcPort),
}},
}}
}), }),
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment