add FlagPersistent flag in nodePort and other situation

This commit is contained in:
Lion-Wei 2017-09-13 14:47:58 +08:00
parent be78d113b1
commit ed802f1db7

View File

@ -952,7 +952,6 @@ func (proxier *Proxier) syncProxyRules(reason syncReason) {
Scheduler: proxier.ipvsScheduler, Scheduler: proxier.ipvsScheduler,
} }
// Set session affinity flag and timeout for IPVS service // Set session affinity flag and timeout for IPVS service
var flags utilipvs.ServiceFlags
if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP { if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP {
serv.Flags |= utilipvs.FlagPersistent serv.Flags |= utilipvs.FlagPersistent
serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds) serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds)
@ -1030,10 +1029,10 @@ func (proxier *Proxier) syncProxyRules(reason syncReason) {
Address: net.ParseIP(externalIP), Address: net.ParseIP(externalIP),
Port: uint16(svcInfo.port), Port: uint16(svcInfo.port),
Protocol: string(svcInfo.protocol), Protocol: string(svcInfo.protocol),
Flags: flags,
Scheduler: proxier.ipvsScheduler, Scheduler: proxier.ipvsScheduler,
} }
if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP { if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP {
serv.Flags |= utilipvs.FlagPersistent
serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds) serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds)
} }
// There is no need to bind externalIP to dummy interface, so set parameter `bindAddr` to `false`. // There is no need to bind externalIP to dummy interface, so set parameter `bindAddr` to `false`.
@ -1091,10 +1090,10 @@ func (proxier *Proxier) syncProxyRules(reason syncReason) {
Address: net.ParseIP(ingress.IP), Address: net.ParseIP(ingress.IP),
Port: uint16(svcInfo.port), Port: uint16(svcInfo.port),
Protocol: string(svcInfo.protocol), Protocol: string(svcInfo.protocol),
Flags: flags,
Scheduler: proxier.ipvsScheduler, Scheduler: proxier.ipvsScheduler,
} }
if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP { if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP {
serv.Flags |= utilipvs.FlagPersistent
serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds) serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds)
} }
// There is no need to bind LB ingress.IP to dummy interface, so set parameter `bindAddr` to `false`. // There is no need to bind LB ingress.IP to dummy interface, so set parameter `bindAddr` to `false`.
@ -1141,10 +1140,10 @@ func (proxier *Proxier) syncProxyRules(reason syncReason) {
Address: nodeIP, Address: nodeIP,
Port: uint16(svcInfo.nodePort), Port: uint16(svcInfo.nodePort),
Protocol: string(svcInfo.protocol), Protocol: string(svcInfo.protocol),
Flags: flags,
Scheduler: proxier.ipvsScheduler, Scheduler: proxier.ipvsScheduler,
} }
if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP { if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP {
serv.Flags |= utilipvs.FlagPersistent
serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds) serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds)
} }
// 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`.