kube-proxy by using IPVS with least connection (lc) scheduler

Jbn1233
1 min readMay 8, 2023

--

a bit old story ,but I need to do it anyway.

$ lsmod |grep ip_vs_lc
ip_vs_lc 16384 6
ip_vs 155648 14 ip_vs_rr,ip_vs_sh,ip_vs_wrr,ip_vs_lc

First you need ipvs installed and loaded ip_vs_lc kernel module.

$ k describe cm -n kube-system kube-proxy |grep -E -A5 "^ipvs"
ipvs:
excludeCIDRs: null
minSyncPeriod: 0s
scheduler: lc
strictARP: false
syncPeriod: 30s

you also need to update kube-proxy config map scheduler=lc

# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.96.0.1:443 lc
-> 192.168.0.161:6443 Masq 1 7 0
TCP 10.96.0.10:53 lc
-> 10.168.75.65:53 Masq 1 0 0
-> 10.168.75.66:53 Masq 1 0 0
TCP 10.96.0.10:9153 lc
-> 10.168.75.65:9153 Masq 1 0 0
-> 10.168.75.66:9153 Masq 1 0 0
TCP 10.96.243.234:80 lc
-> 10.168.114.129:8080 Masq 1 0 0
-> 10.168.114.131:8080 Masq 1 0 0

verify the result with ipvsadm command.

10.96.x.x = svc CIDR and 10.168.x.x = pod CIDR

lc at the end of line means this svc IP have least connection (lc) scheduler.

Remember, the least connection schedule scope is only on local worker not cluster level.

that’s all.

--

--

Jbn1233
Jbn1233

Written by Jbn1233

Very short and simple notes for CKA/SRE and may not works on your environment | jbn1233@gmail.com | Bangkok, Thailand |

No responses yet