@@ -117,6 +117,11 @@ func EndpointsUseHostNetwork(config *NetworkingTestConfig) {
117
117
config .EndpointsHostNetwork = true
118
118
}
119
119
120
+ // PreferExternalAddresses prefer node External Addresses for the tests
121
+ func PreferExternalAddresses (config * NetworkingTestConfig ) {
122
+ config .PreferExternalAddresses = true
123
+ }
124
+
120
125
// NewNetworkingTestConfig creates and sets up a new test config helper.
121
126
func NewNetworkingTestConfig (f * framework.Framework , setters ... Option ) * NetworkingTestConfig {
122
127
// default options
@@ -205,6 +210,8 @@ type NetworkingTestConfig struct {
205
210
// The kubernetes namespace within which all resources for this
206
211
// config are created
207
212
Namespace string
213
+ // Whether to prefer node External Addresses for the tests
214
+ PreferExternalAddresses bool
208
215
}
209
216
210
217
// NetexecDialResponse represents the response returned by the `netexec` subcommand of `agnhost`
@@ -817,13 +824,17 @@ func (config *NetworkingTestConfig) setup(selector map[string]string) {
817
824
family = v1 .IPv6Protocol
818
825
secondaryFamily = v1 .IPv4Protocol
819
826
}
820
- // Get Node IPs from the cluster, ExternalIPs take precedence
821
- config .NodeIP = e2enode .FirstAddressByTypeAndFamily (nodeList , v1 .NodeExternalIP , family )
827
+ if config .PreferExternalAddresses {
828
+ // Get Node IPs from the cluster, ExternalIPs take precedence
829
+ config .NodeIP = e2enode .FirstAddressByTypeAndFamily (nodeList , v1 .NodeExternalIP , family )
830
+ }
822
831
if config .NodeIP == "" {
823
832
config .NodeIP = e2enode .FirstAddressByTypeAndFamily (nodeList , v1 .NodeInternalIP , family )
824
833
}
825
834
if config .DualStackEnabled {
826
- config .SecondaryNodeIP = e2enode .FirstAddressByTypeAndFamily (nodeList , v1 .NodeExternalIP , secondaryFamily )
835
+ if config .PreferExternalAddresses {
836
+ config .SecondaryNodeIP = e2enode .FirstAddressByTypeAndFamily (nodeList , v1 .NodeExternalIP , secondaryFamily )
837
+ }
827
838
if config .SecondaryNodeIP == "" {
828
839
config .SecondaryNodeIP = e2enode .FirstAddressByTypeAndFamily (nodeList , v1 .NodeInternalIP , secondaryFamily )
829
840
}
0 commit comments