diff --git a/cmd/minikube/cmd/service_list.go b/cmd/minikube/cmd/service_list.go index 9d86d5a8b8ca..7dddcd826cc0 100644 --- a/cmd/minikube/cmd/service_list.go +++ b/cmd/minikube/cmd/service_list.go @@ -66,6 +66,7 @@ var serviceListCmd = &cobra.Command{ if len(serviceURL.URLs) == 0 { data = append(data, []string{serviceURL.Namespace, serviceURL.Name, "No node port"}) } else { + servicePortNames := strings.Join(serviceURL.PortNames, "\n") serviceURLs := strings.Join(serviceURL.URLs, "\n") // if we are running Docker on OSX we empty the internal service URLs @@ -73,7 +74,7 @@ var serviceListCmd = &cobra.Command{ serviceURLs = "" } - data = append(data, []string{serviceURL.Namespace, serviceURL.Name, "", serviceURLs}) + data = append(data, []string{serviceURL.Namespace, serviceURL.Name, servicePortNames, serviceURLs}) } } diff --git a/pkg/minikube/service/service.go b/pkg/minikube/service/service.go index 3f3c159cd4e6..16579e31b30e 100644 --- a/pkg/minikube/service/service.go +++ b/pkg/minikube/service/service.go @@ -22,6 +22,7 @@ import ( "io" "net/url" "os" + "strconv" "strings" "text/template" "time" @@ -196,6 +197,13 @@ func printURLsForService(c typed_core.CoreV1Interface, ip, service, namespace st urls := []string{} portNames := []string{} for _, port := range svc.Spec.Ports { + + if port.Name != "" { + m[port.TargetPort.IntVal] = port.Name + } else { + m[port.TargetPort.IntVal] = strconv.Itoa(int(port.Port)) + } + if port.NodePort > 0 { var doc bytes.Buffer err = t.Execute(&doc, struct {