mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Kube-proxy: Get nodeIPs for both families with dual-stack (#119525)
* Kube-proxy: handle dual-stack in detectNodeIPs() * Updates
This commit is contained in:
@@ -634,30 +634,30 @@ func Test_detectNodeIPs(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "Bind address IPv4 unicast address and no Node object",
|
||||
nodeInfo: makeNodeWithAddresses("", "", ""),
|
||||
nodeInfo: makeNodeWithAddresses("fakeHost", "", ""),
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "10.0.0.1",
|
||||
expectedFamily: v1.IPv4Protocol,
|
||||
expectedIPv4: "10.0.0.1",
|
||||
expectedIPv6: "::",
|
||||
expectedIPv6: "::1",
|
||||
},
|
||||
{
|
||||
name: "Bind address IPv6 unicast address and no Node object",
|
||||
nodeInfo: makeNodeWithAddresses("", "", ""),
|
||||
nodeInfo: makeNodeWithAddresses("fakeHost", "", ""),
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "fd00:4321::2",
|
||||
expectedFamily: v1.IPv6Protocol,
|
||||
expectedIPv4: "0.0.0.0",
|
||||
expectedIPv4: "127.0.0.1",
|
||||
expectedIPv6: "fd00:4321::2",
|
||||
},
|
||||
{
|
||||
name: "No Valid IP found",
|
||||
nodeInfo: makeNodeWithAddresses("", "", ""),
|
||||
nodeInfo: makeNodeWithAddresses("fakeHost", "", ""),
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "",
|
||||
expectedFamily: v1.IPv4Protocol,
|
||||
expectedIPv4: "127.0.0.1",
|
||||
expectedIPv6: "::",
|
||||
expectedIPv6: "::1",
|
||||
},
|
||||
// Disabled because the GetNodeIP method has a backoff retry mechanism
|
||||
// and the test takes more than 30 seconds
|
||||
@@ -678,7 +678,7 @@ func Test_detectNodeIPs(t *testing.T) {
|
||||
bindAddress: "0.0.0.0",
|
||||
expectedFamily: v1.IPv4Protocol,
|
||||
expectedIPv4: "192.168.1.1",
|
||||
expectedIPv6: "::",
|
||||
expectedIPv6: "::1",
|
||||
},
|
||||
{
|
||||
name: "Bind address :: and node with IPv4 InternalIP set",
|
||||
@@ -687,7 +687,7 @@ func Test_detectNodeIPs(t *testing.T) {
|
||||
bindAddress: "::",
|
||||
expectedFamily: v1.IPv4Protocol,
|
||||
expectedIPv4: "192.168.1.1",
|
||||
expectedIPv6: "::",
|
||||
expectedIPv6: "::1",
|
||||
},
|
||||
{
|
||||
name: "Bind address 0.0.0.0 and node with IPv6 InternalIP set",
|
||||
@@ -695,7 +695,7 @@ func Test_detectNodeIPs(t *testing.T) {
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "0.0.0.0",
|
||||
expectedFamily: v1.IPv6Protocol,
|
||||
expectedIPv4: "0.0.0.0",
|
||||
expectedIPv4: "127.0.0.1",
|
||||
expectedIPv6: "fd00:1234::1",
|
||||
},
|
||||
{
|
||||
@@ -704,7 +704,7 @@ func Test_detectNodeIPs(t *testing.T) {
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "::",
|
||||
expectedFamily: v1.IPv6Protocol,
|
||||
expectedIPv4: "0.0.0.0",
|
||||
expectedIPv4: "127.0.0.1",
|
||||
expectedIPv6: "fd00:1234::1",
|
||||
},
|
||||
{
|
||||
@@ -714,7 +714,7 @@ func Test_detectNodeIPs(t *testing.T) {
|
||||
bindAddress: "0.0.0.0",
|
||||
expectedFamily: v1.IPv4Protocol,
|
||||
expectedIPv4: "90.90.90.90",
|
||||
expectedIPv6: "::",
|
||||
expectedIPv6: "::1",
|
||||
},
|
||||
{
|
||||
name: "Bind address :: and node with only IPv4 ExternalIP set",
|
||||
@@ -723,7 +723,7 @@ func Test_detectNodeIPs(t *testing.T) {
|
||||
bindAddress: "::",
|
||||
expectedFamily: v1.IPv4Protocol,
|
||||
expectedIPv4: "90.90.90.90",
|
||||
expectedIPv6: "::",
|
||||
expectedIPv6: "::1",
|
||||
},
|
||||
{
|
||||
name: "Bind address 0.0.0.0 and node with only IPv6 ExternalIP set",
|
||||
@@ -731,7 +731,7 @@ func Test_detectNodeIPs(t *testing.T) {
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "0.0.0.0",
|
||||
expectedFamily: v1.IPv6Protocol,
|
||||
expectedIPv4: "0.0.0.0",
|
||||
expectedIPv4: "127.0.0.1",
|
||||
expectedIPv6: "2001:db8::2",
|
||||
},
|
||||
{
|
||||
@@ -740,9 +740,63 @@ func Test_detectNodeIPs(t *testing.T) {
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "::",
|
||||
expectedFamily: v1.IPv6Protocol,
|
||||
expectedIPv4: "0.0.0.0",
|
||||
expectedIPv4: "127.0.0.1",
|
||||
expectedIPv6: "2001:db8::2",
|
||||
},
|
||||
{
|
||||
name: "Dual stack, primary IPv4",
|
||||
nodeInfo: makeNodeWithAddresses("fakeHost", "90.90.90.90", "2001:db8::2"),
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "::",
|
||||
expectedFamily: v1.IPv4Protocol,
|
||||
expectedIPv4: "90.90.90.90",
|
||||
expectedIPv6: "2001:db8::2",
|
||||
},
|
||||
{
|
||||
name: "Dual stack, primary IPv6",
|
||||
nodeInfo: makeNodeWithAddresses("fakeHost", "2001:db8::2", "90.90.90.90"),
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "0.0.0.0",
|
||||
expectedFamily: v1.IPv6Protocol,
|
||||
expectedIPv4: "90.90.90.90",
|
||||
expectedIPv6: "2001:db8::2",
|
||||
},
|
||||
{
|
||||
name: "Dual stack, override IPv4",
|
||||
nodeInfo: makeNodeWithAddresses("fakeHost", "2001:db8::2", "90.90.90.90"),
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "80.80.80.80",
|
||||
expectedFamily: v1.IPv4Protocol,
|
||||
expectedIPv4: "80.80.80.80",
|
||||
expectedIPv6: "2001:db8::2",
|
||||
},
|
||||
{
|
||||
name: "Dual stack, override IPv6",
|
||||
nodeInfo: makeNodeWithAddresses("fakeHost", "90.90.90.90", "2001:db8::2"),
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "2001:db8::555",
|
||||
expectedFamily: v1.IPv6Protocol,
|
||||
expectedIPv4: "90.90.90.90",
|
||||
expectedIPv6: "2001:db8::555",
|
||||
},
|
||||
{
|
||||
name: "Dual stack, override primary family, IPv4",
|
||||
nodeInfo: makeNodeWithAddresses("fakeHost", "2001:db8::2", "90.90.90.90"),
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "127.0.0.1",
|
||||
expectedFamily: v1.IPv4Protocol,
|
||||
expectedIPv4: "127.0.0.1",
|
||||
expectedIPv6: "2001:db8::2",
|
||||
},
|
||||
{
|
||||
name: "Dual stack, override primary family, IPv6",
|
||||
nodeInfo: makeNodeWithAddresses("fakeHost", "90.90.90.90", "2001:db8::2"),
|
||||
hostname: "fakeHost",
|
||||
bindAddress: "::1",
|
||||
expectedFamily: v1.IPv6Protocol,
|
||||
expectedIPv4: "90.90.90.90",
|
||||
expectedIPv6: "::1",
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user