Skip to content

Commit

Permalink
Add support for builtin modules in kube-proxy
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@serpro.gov.br>
  • Loading branch information
Ricardo Pchevuzinske Katz committed Oct 23, 2019
1 parent 9fa1bc8 commit 6aaae7d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pkg/proxy/ipvs/proxier.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,24 @@ func (handle *LinuxKernelHandler) GetModules() ([]string, error) {

var bmods []string

// Find out loaded kernel modules. If this is a full static kernel it will thrown an error
// 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
modulesFile, err := os.Open("/proc/modules")
if err == os.ErrNotExist {
klog.Warningf("Failed to read file /proc/modules with error %v. Assuming this is a kernel without loadable modules support enabled", err)
kernelConfigFile := fmt.Sprintf("/boot/config-%s", kernelVersionStr)
kConfig, err := ioutil.ReadFile(kernelConfigFile)
if err != nil {
return nil, fmt.Errorf("Failed to read Kernel Config file %s with error %v", kernelConfigFile, err)
}
for _, module := range ipvsModules {
if match, _ := regexp.Match("CONFIG_"+strings.ToUpper(module)+"=y", kConfig); match {
bmods = append(bmods, module)
}
}
return bmods, nil
}
if err != nil {
klog.Warningf("Failed to read file /proc/modules with error %v. Kube-proxy requires loadable modules support enabled in the kernel", err)
return nil, err
return nil, fmt.Errorf("Failed to read file /proc/modules with error %v", err)
}

mods, err := getFirstColumn(modulesFile)
Expand Down

0 comments on commit 6aaae7d

Please sign in to comment.