[kube-proxy] Fix session affinity with local endpoints traffic

This commit is contained in:
Zihong Zheng
2017-11-10 18:42:07 -08:00
parent 113bf2567d
commit f7ed9cf09a
3 changed files with 31 additions and 1 deletions

View File

@@ -1516,6 +1516,18 @@ func (proxier *Proxier) syncProxyRules() {
)
writeLine(proxier.natRules, args...)
} else {
// First write session affinity rules only over local endpoints, if applicable.
if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP {
for _, endpointChain := range localEndpointChains {
writeLine(proxier.natRules,
"-A", string(svcXlbChain),
"-m", "comment", "--comment", svcNameString,
"-m", "recent", "--name", string(endpointChain),
"--rcheck", "--seconds", strconv.Itoa(svcInfo.stickyMaxAgeSeconds), "--reap",
"-j", string(endpointChain))
}
}
// Setup probability filter rules only over local endpoints
for i, endpointChain := range localEndpointChains {
// Balancing rules in the per-service chain.