mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
commit
dfea6456f1
@ -1028,11 +1028,9 @@ func (proxier *Proxier) syncProxyRules() {
|
||||
serv.Timeout = uint32(svcInfo.StickyMaxAgeSeconds)
|
||||
}
|
||||
if err := proxier.syncService(svcNameString, serv, true); err == nil {
|
||||
// check if service need skip endpoints that not in same host as kube-proxy
|
||||
onlyLocal := svcInfo.SessionAffinityType == v1.ServiceAffinityClientIP && svcInfo.OnlyNodeLocalEndpoints
|
||||
activeIPVSServices[serv.String()] = true
|
||||
activeBindAddrs[serv.Address.String()] = true
|
||||
if err := proxier.syncEndpoint(svcName, onlyLocal, serv); err != nil {
|
||||
if err := proxier.syncEndpoint(svcName, svcInfo.OnlyNodeLocalEndpoints, serv); err != nil {
|
||||
klog.Errorf("Failed to sync endpoint for service: %v, err: %v", serv, err)
|
||||
}
|
||||
} else {
|
||||
|
@ -1266,18 +1266,32 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
|
||||
)
|
||||
|
||||
epIP := "10.180.0.1"
|
||||
epIP1 := "10.180.1.1"
|
||||
thisHostname := testHostname
|
||||
otherHostname := "other-hostname"
|
||||
|
||||
makeEndpointsMap(fp,
|
||||
makeTestEndpoints(svcPortName.Namespace, svcPortName.Name, func(ept *v1.Endpoints) {
|
||||
ept.Subsets = []v1.EndpointSubset{{
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
IP: epIP,
|
||||
NodeName: nil,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
}},
|
||||
}}
|
||||
ept.Subsets = []v1.EndpointSubset{
|
||||
{ // **local** endpoint address, should be added as RS
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
IP: epIP,
|
||||
NodeName: &thisHostname,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
}}},
|
||||
{ // **remote** endpoint address, should not be added as RS
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
IP: epIP1,
|
||||
NodeName: &otherHostname,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user