Skip to content

Commit 6aaae7d

Browse files
author
Ricardo Pchevuzinske Katz
committed
Add support for builtin modules in kube-proxy
Signed-off-by: Ricardo Pchevuzinske Katz <[email protected]>
1 parent 9fa1bc8 commit 6aaae7d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pkg/proxy/ipvs/proxier.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,24 @@ func (handle *LinuxKernelHandler) GetModules() ([]string, error) {
582582

583583
var bmods []string
584584

585-
// Find out loaded kernel modules. If this is a full static kernel it will thrown an error
585+
// Find out loaded kernel modules. If this is a full static kernel it will try to verify if the module is compiled using /boot/config-KERNELVERSION
586586
modulesFile, err := os.Open("/proc/modules")
587+
if err == os.ErrNotExist {
588+
klog.Warningf("Failed to read file /proc/modules with error %v. Assuming this is a kernel without loadable modules support enabled", err)
589+
kernelConfigFile := fmt.Sprintf("/boot/config-%s", kernelVersionStr)
590+
kConfig, err := ioutil.ReadFile(kernelConfigFile)
591+
if err != nil {
592+
return nil, fmt.Errorf("Failed to read Kernel Config file %s with error %v", kernelConfigFile, err)
593+
}
594+
for _, module := range ipvsModules {
595+
if match, _ := regexp.Match("CONFIG_"+strings.ToUpper(module)+"=y", kConfig); match {
596+
bmods = append(bmods, module)
597+
}
598+
}
599+
return bmods, nil
600+
}
587601
if err != nil {
588-
klog.Warningf("Failed to read file /proc/modules with error %v. Kube-proxy requires loadable modules support enabled in the kernel", err)
589-
return nil, err
602+
return nil, fmt.Errorf("Failed to read file /proc/modules with error %v", err)
590603
}
591604

592605
mods, err := getFirstColumn(modulesFile)

0 commit comments

Comments
 (0)