mirror of
https://github.com/kubernetes-sigs/kind.git
synced 2025-12-01 07:26:05 +07:00
Setting the default hostIP for get kubeconfig
Update pkg/cluster/internal/providers/podman/provider.go Co-authored-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
This commit is contained in:
@@ -171,6 +171,15 @@ func (p *provider) DeleteNodes(n []nodes.Node) error {
|
|||||||
return deleteVolumes(nodeVolumes)
|
return deleteVolumes(nodeVolumes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getHostIPOrDefault defaults HostIP to localhost if is not set
|
||||||
|
// xref: https://github.com/kubernetes-sigs/kind/issues/3777
|
||||||
|
func getHostIPOrDefault(hostIP string) string {
|
||||||
|
if hostIP == "" {
|
||||||
|
return "127.0.0.1"
|
||||||
|
}
|
||||||
|
return hostIP
|
||||||
|
}
|
||||||
|
|
||||||
// GetAPIServerEndpoint is part of the providers.Provider interface
|
// GetAPIServerEndpoint is part of the providers.Provider interface
|
||||||
func (p *provider) GetAPIServerEndpoint(cluster string) (string, error) {
|
func (p *provider) GetAPIServerEndpoint(cluster string) (string, error) {
|
||||||
// locate the node that hosts this
|
// locate the node that hosts this
|
||||||
@@ -266,7 +275,7 @@ func (p *provider) GetAPIServerEndpoint(cluster string) (string, error) {
|
|||||||
}
|
}
|
||||||
for _, pm := range v {
|
for _, pm := range v {
|
||||||
if containerPort == common.APIServerInternalPort && protocol == "tcp" {
|
if containerPort == common.APIServerInternalPort && protocol == "tcp" {
|
||||||
return net.JoinHostPort(pm.HostIP, pm.HostPort), nil
|
return net.JoinHostPort(getHostIPOrDefault(pm.HostIP), pm.HostPort), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,7 +287,7 @@ func (p *provider) GetAPIServerEndpoint(cluster string) (string, error) {
|
|||||||
}
|
}
|
||||||
for _, pm := range portMappings19 {
|
for _, pm := range portMappings19 {
|
||||||
if pm.ContainerPort == common.APIServerInternalPort && pm.Protocol == "tcp" {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user