Skip to content

Commit

Permalink
Setting the default hostIP for get kubeconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
kebe7jun committed Nov 6, 2024
1 parent 1a8f047 commit dbf2bd3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/cluster/internal/providers/podman/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ func (p *provider) DeleteNodes(n []nodes.Node) error {
return deleteVolumes(nodeVolumes)
}

func getHostIPOrDefault(hostIP string) string {
if hostIP == "" {
return "127.0.0.1"
}
return hostIP
}

// GetAPIServerEndpoint is part of the providers.Provider interface
func (p *provider) GetAPIServerEndpoint(cluster string) (string, error) {
// locate the node that hosts this
Expand Down Expand Up @@ -266,7 +273,7 @@ func (p *provider) GetAPIServerEndpoint(cluster string) (string, error) {
}
for _, pm := range v {
if containerPort == common.APIServerInternalPort && protocol == "tcp" {
return net.JoinHostPort(pm.HostIP, pm.HostPort), nil
return net.JoinHostPort(getHostIPOrDefault(pm.HostIP), pm.HostPort), nil
}
}
}
Expand All @@ -278,7 +285,7 @@ func (p *provider) GetAPIServerEndpoint(cluster string) (string, error) {
}
for _, pm := range portMappings19 {
if pm.ContainerPort == common.APIServerInternalPort && pm.Protocol == "tcp" {
return net.JoinHostPort(pm.HostIP, strconv.Itoa(int(pm.HostPort))), nil
return net.JoinHostPort(getHostIPOrDefault(pm.HostIP), strconv.Itoa(int(pm.HostPort))), nil
}
}

Expand Down

0 comments on commit dbf2bd3

Please sign in to comment.