mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Allow disabling nftables kernel version check
This commit is contained in:
		@@ -29,6 +29,7 @@ import (
 | 
				
			|||||||
	"encoding/base32"
 | 
						"encoding/base32"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"net"
 | 
						"net"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
@@ -296,6 +297,10 @@ 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
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
 | 
						// However, we allow the user to bypass this check by setting
 | 
				
			||||||
 | 
						// `KUBE_PROXY_NFTABLES_SKIP_KERNEL_VERSION_CHECK` to anything non-empty.
 | 
				
			||||||
 | 
						if os.Getenv("KUBE_PROXY_NFTABLES_SKIP_KERNEL_VERSION_CHECK") != "" {
 | 
				
			||||||
		kernelVersion, err := utilkernel.GetVersion()
 | 
							kernelVersion, err := utilkernel.GetVersion()
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("could not check kernel version: %w", err)
 | 
								return nil, fmt.Errorf("could not check kernel version: %w", err)
 | 
				
			||||||
@@ -303,6 +308,7 @@ func getNFTablesInterface(ipFamily v1.IPFamily) (knftables.Interface, error) {
 | 
				
			|||||||
		if kernelVersion.LessThan(version.MustParseGeneric(utilkernel.NFTablesKubeProxyKernelVersion)) {
 | 
							if kernelVersion.LessThan(version.MustParseGeneric(utilkernel.NFTablesKubeProxyKernelVersion)) {
 | 
				
			||||||
			return nil, fmt.Errorf("kube-proxy in nftables mode requires kernel %s or later", utilkernel.NFTablesKubeProxyKernelVersion)
 | 
								return nil, fmt.Errorf("kube-proxy in nftables mode requires kernel %s or later", utilkernel.NFTablesKubeProxyKernelVersion)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nft, nil
 | 
						return nft, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user