@@ -171,6 +171,15 @@ func (p *provider) DeleteNodes(n []nodes.Node) error {
171
171
return deleteVolumes (nodeVolumes )
172
172
}
173
173
174
+ // getHostIPOrDefault defaults HostIP to localhost if is not set
175
+ // xref: https://github.com/kubernetes-sigs/kind/issues/3777
176
+ func getHostIPOrDefault (hostIP string ) string {
177
+ if hostIP == "" {
178
+ return "127.0.0.1"
179
+ }
180
+ return hostIP
181
+ }
182
+
174
183
// GetAPIServerEndpoint is part of the providers.Provider interface
175
184
func (p * provider ) GetAPIServerEndpoint (cluster string ) (string , error ) {
176
185
// locate the node that hosts this
@@ -266,7 +275,7 @@ func (p *provider) GetAPIServerEndpoint(cluster string) (string, error) {
266
275
}
267
276
for _ , pm := range v {
268
277
if containerPort == common .APIServerInternalPort && protocol == "tcp" {
269
- return net .JoinHostPort (pm .HostIP , pm .HostPort ), nil
278
+ return net .JoinHostPort (getHostIPOrDefault ( pm .HostIP ) , pm .HostPort ), nil
270
279
}
271
280
}
272
281
}
@@ -278,7 +287,7 @@ func (p *provider) GetAPIServerEndpoint(cluster string) (string, error) {
278
287
}
279
288
for _ , pm := range portMappings19 {
280
289
if pm .ContainerPort == common .APIServerInternalPort && pm .Protocol == "tcp" {
281
- return net .JoinHostPort (pm .HostIP , strconv .Itoa (int (pm .HostPort ))), nil
290
+ return net .JoinHostPort (getHostIPOrDefault ( pm .HostIP ) , strconv .Itoa (int (pm .HostPort ))), nil
282
291
}
283
292
}
284
293
0 commit comments