mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Allow disabling nftables kernel version check
This commit is contained in:
parent
505f6833d9
commit
b39fd03ee4
@ -29,6 +29,7 @@ import (
|
|||||||
"encoding/base32"
|
"encoding/base32"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -296,12 +297,17 @@ func getNFTablesInterface(ipFamily v1.IPFamily) (knftables.Interface, error) {
|
|||||||
// check the kernel version, under the assumption that the distro will have an nft
|
// check the kernel version, under the assumption that the distro will have an nft
|
||||||
// binary that supports the same features as its kernel does, and so kernel 5.13
|
// binary that supports the same features as its kernel does, and so kernel 5.13
|
||||||
// or later implies nft 1.0.1 or later. https://issues.k8s.io/122743
|
// or later implies nft 1.0.1 or later. https://issues.k8s.io/122743
|
||||||
kernelVersion, err := utilkernel.GetVersion()
|
//
|
||||||
if err != nil {
|
// However, we allow the user to bypass this check by setting
|
||||||
return nil, fmt.Errorf("could not check kernel version: %w", err)
|
// `KUBE_PROXY_NFTABLES_SKIP_KERNEL_VERSION_CHECK` to anything non-empty.
|
||||||
}
|
if os.Getenv("KUBE_PROXY_NFTABLES_SKIP_KERNEL_VERSION_CHECK") != "" {
|
||||||
if kernelVersion.LessThan(version.MustParseGeneric(utilkernel.NFTablesKubeProxyKernelVersion)) {
|
kernelVersion, err := utilkernel.GetVersion()
|
||||||
return nil, fmt.Errorf("kube-proxy in nftables mode requires kernel %s or later", utilkernel.NFTablesKubeProxyKernelVersion)
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("could not check kernel version: %w", err)
|
||||||
|
}
|
||||||
|
if kernelVersion.LessThan(version.MustParseGeneric(utilkernel.NFTablesKubeProxyKernelVersion)) {
|
||||||
|
return nil, fmt.Errorf("kube-proxy in nftables mode requires kernel %s or later", utilkernel.NFTablesKubeProxyKernelVersion)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nft, nil
|
return nft, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user