@@ -1152,7 +1152,16 @@ func (proxier *Proxier) syncProxyRules() {
1152
1152
1153
1153
// Now write loadbalancing & DNAT rules.
1154
1154
n := len (endpointChains )
1155
+ localEndpoints := make ([]* endpointsInfo , 0 )
1156
+ localEndpointChains := make ([]utiliptables.Chain , 0 )
1155
1157
for i , endpointChain := range endpointChains {
1158
+ // Write ingress loadbalancing & DNAT rules only for services that request OnlyLocal traffic.
1159
+ if svcInfo .OnlyNodeLocalEndpoints && endpoints [i ].IsLocal {
1160
+ // These slices parallel each other; must be kept in sync
1161
+ localEndpoints = append (localEndpoints , endpoints [i ])
1162
+ localEndpointChains = append (localEndpointChains , endpointChains [i ])
1163
+ }
1164
+
1156
1165
epIP := endpoints [i ].IP ()
1157
1166
if epIP == "" {
1158
1167
// Error parsing this endpoint has been logged. Skip to next endpoint.
@@ -1193,17 +1202,6 @@ func (proxier *Proxier) syncProxyRules() {
1193
1202
continue
1194
1203
}
1195
1204
1196
- // Now write ingress loadbalancing & DNAT rules only for services that request OnlyLocal traffic.
1197
- // TODO - This logic may be combinable with the block above that creates the svc balancer chain
1198
- localEndpoints := make ([]* endpointsInfo , 0 )
1199
- localEndpointChains := make ([]utiliptables.Chain , 0 )
1200
- for i := range endpointChains {
1201
- if endpoints [i ].IsLocal {
1202
- // These slices parallel each other; must be kept in sync
1203
- localEndpoints = append (localEndpoints , endpoints [i ])
1204
- localEndpointChains = append (localEndpointChains , endpointChains [i ])
1205
- }
1206
- }
1207
1205
// First rule in the chain redirects all pod -> external VIP traffic to the
1208
1206
// Service's ClusterIP instead. This happens whether or not we have local
1209
1207
// endpoints; only if clusterCIDR is specified
0 commit comments