mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
kube-proxy detect IP family based on nodeIP
We were detecting the IP family that kube-proxy should use based on the bind address, however, this is not valid when using an unspecified address, because on those cases kube-proxy adopts the IP family of the address reported in the Node API object. The IP family will be determined by the nodeIP used by the proxier The order of precedence is: 1. config.bindAddress if bindAddress is not 0.0.0.0 or :: 2. the primary IP from the Node object, if set 3. if no IP is found it defaults to 127.0.0.1 and IPv4 Signed-off-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
This commit is contained in:
@@ -36,36 +36,9 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
componentbaseconfig "k8s.io/component-base/config"
|
||||
"k8s.io/component-base/configz"
|
||||
kubeproxyconfig "k8s.io/kubernetes/pkg/proxy/apis/config"
|
||||
)
|
||||
|
||||
// This test verifies that NewProxyServer does not crash when CleanupAndExit is true.
|
||||
func TestProxyServerWithCleanupAndExit(t *testing.T) {
|
||||
// Each bind address below is a separate test case
|
||||
bindAddresses := []string{
|
||||
"0.0.0.0",
|
||||
"::",
|
||||
}
|
||||
for _, addr := range bindAddresses {
|
||||
options := NewOptions()
|
||||
|
||||
options.config = &kubeproxyconfig.KubeProxyConfiguration{
|
||||
BindAddress: addr,
|
||||
}
|
||||
options.CleanupAndExit = true
|
||||
|
||||
proxyserver, err := NewProxyServer(options)
|
||||
|
||||
assert.Nil(t, err, "unexpected error in NewProxyServer, addr: %s", addr)
|
||||
assert.NotNil(t, proxyserver, "nil proxy server obj, addr: %s", addr)
|
||||
assert.NotNil(t, proxyserver.IptInterface, "nil iptables intf, addr: %s", addr)
|
||||
|
||||
// Clean up config for next test case
|
||||
configz.Delete(kubeproxyconfig.GroupName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetConntrackMax(t *testing.T) {
|
||||
ncores := runtime.NumCPU()
|
||||
testCases := []struct {
|
||||
|
||||
Reference in New Issue
Block a user