improve kube-vip cp lb auto-enable

pull/18376/head
Predrag Rogic 2024-03-13 18:36:02 +00:00
parent e5aeab1d1c
commit b0e3e092e1
No known key found for this signature in database
GPG Key ID: F1FF5748C4855229
1 changed files with 8 additions and 10 deletions

View File

@ -147,18 +147,16 @@ func enableCPLB(cc config.ClusterConfig, r command.Runner, kubeadmCfg []byte) bo
return false
}
// for non-vm driver, try to check if required ipvs kernel modules are loaded to enable kube-vip's control-plane load-balancing feature
if !driver.IsVM(cc.Driver) {
if _, err := r.RunCmd(exec.Command("sudo", "sh", "-c", "lsmod | grep ip_vs")); err != nil {
klog.Errorf("giving up enabling control-plane load-balancing as ipvs kernel modules appears not to be present: %v", err)
return false
}
}
// for vm driver, ensure required ipvs kernel modules are loaded to enable kube-vip's control-plane load-balancing feature
// ref: https://github.com/kubernetes/kubernetes/blob/f90461c43e881d320b78d48793db10c110d488d1/pkg/proxy/ipvs/README.md?plain=1#L257-L269
if _, err := r.RunCmd(exec.Command("sudo", "sh", "-c", "modprobe --all ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh nf_conntrack")); err != nil {
klog.Errorf("unable to load ipvs kernel modules: %v", err)
if driver.IsVM(cc.Driver) {
if _, err := r.RunCmd(exec.Command("sudo", "sh", "-c", "modprobe --all ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh nf_conntrack")); err != nil {
klog.Errorf("unable to load ipvs kernel modules: %v", err)
return false
}
// for non-vm driver, only try to check if required ipvs kernel modules are already loaded
} else if _, err := r.RunCmd(exec.Command("sudo", "sh", "-c", "lsmod | grep ip_vs")); err != nil {
klog.Errorf("giving up enabling control-plane load-balancing as ipvs kernel modules appears not to be present: %v", err)
return false
}