mirror of https://github.com/k3s-io/k3s
Merge pull request #7557 from piosz/kubectl
Added displaying external IPs to kubectl cluster-infopull/6/head
commit
c455600784
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
|
||||
|
@ -70,7 +71,14 @@ func RunClusterInfo(factory *cmdutil.Factory, out io.Writer, cmd *cobra.Command)
|
|||
b.Do().Visit(func(r *resource.Info) error {
|
||||
services := r.Object.(*api.ServiceList).Items
|
||||
for _, service := range services {
|
||||
link := client.Host + "/api/v1beta3/proxy/namespaces/" + service.ObjectMeta.Namespace + "/services/" + service.ObjectMeta.Name
|
||||
var link string
|
||||
if len(service.Spec.PublicIPs) > 0 {
|
||||
for _, port := range service.Spec.Ports {
|
||||
link += "http://" + service.Spec.PublicIPs[0] + ":" + strconv.Itoa(port.Port) + " "
|
||||
}
|
||||
} else {
|
||||
link = client.Host + "/api/v1beta3/proxy/namespaces/" + service.ObjectMeta.Namespace + "/services/" + service.ObjectMeta.Name
|
||||
}
|
||||
printService(out, service.ObjectMeta.Labels["name"], link)
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue