mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #113799 from r4f4/nettest-priv-ip
tests: network: Prefer internal IPs first
This commit is contained in:
commit
55181b72a2
@ -117,6 +117,11 @@ func EndpointsUseHostNetwork(config *NetworkingTestConfig) {
|
|||||||
config.EndpointsHostNetwork = true
|
config.EndpointsHostNetwork = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PreferExternalAddresses prefer node External Addresses for the tests
|
||||||
|
func PreferExternalAddresses(config *NetworkingTestConfig) {
|
||||||
|
config.PreferExternalAddresses = true
|
||||||
|
}
|
||||||
|
|
||||||
// NewNetworkingTestConfig creates and sets up a new test config helper.
|
// NewNetworkingTestConfig creates and sets up a new test config helper.
|
||||||
func NewNetworkingTestConfig(ctx context.Context, f *framework.Framework, setters ...Option) *NetworkingTestConfig {
|
func NewNetworkingTestConfig(ctx context.Context, f *framework.Framework, setters ...Option) *NetworkingTestConfig {
|
||||||
// default options
|
// default options
|
||||||
@ -205,6 +210,8 @@ type NetworkingTestConfig struct {
|
|||||||
// The kubernetes namespace within which all resources for this
|
// The kubernetes namespace within which all resources for this
|
||||||
// config are created
|
// config are created
|
||||||
Namespace string
|
Namespace string
|
||||||
|
// Whether to prefer node External Addresses for the tests
|
||||||
|
PreferExternalAddresses bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetexecDialResponse represents the response returned by the `netexec` subcommand of `agnhost`
|
// NetexecDialResponse represents the response returned by the `netexec` subcommand of `agnhost`
|
||||||
@ -817,13 +824,17 @@ func (config *NetworkingTestConfig) setup(ctx context.Context, selector map[stri
|
|||||||
family = v1.IPv6Protocol
|
family = v1.IPv6Protocol
|
||||||
secondaryFamily = v1.IPv4Protocol
|
secondaryFamily = v1.IPv4Protocol
|
||||||
}
|
}
|
||||||
|
if config.PreferExternalAddresses {
|
||||||
// Get Node IPs from the cluster, ExternalIPs take precedence
|
// Get Node IPs from the cluster, ExternalIPs take precedence
|
||||||
config.NodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeExternalIP, family)
|
config.NodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeExternalIP, family)
|
||||||
|
}
|
||||||
if config.NodeIP == "" {
|
if config.NodeIP == "" {
|
||||||
config.NodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeInternalIP, family)
|
config.NodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeInternalIP, family)
|
||||||
}
|
}
|
||||||
if config.DualStackEnabled {
|
if config.DualStackEnabled {
|
||||||
|
if config.PreferExternalAddresses {
|
||||||
config.SecondaryNodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeExternalIP, secondaryFamily)
|
config.SecondaryNodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeExternalIP, secondaryFamily)
|
||||||
|
}
|
||||||
if config.SecondaryNodeIP == "" {
|
if config.SecondaryNodeIP == "" {
|
||||||
config.SecondaryNodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeInternalIP, secondaryFamily)
|
config.SecondaryNodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeInternalIP, secondaryFamily)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user