mirror of https://github.com/k3s-io/k3s
Print named ports in 'describe service'
Also in 'describe service'. This got missed in all the multiport work.pull/6/head
parent
45d8c97b0b
commit
eea949b3a3
|
@ -29,6 +29,7 @@ import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -457,8 +458,8 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
|
||||||
name = "<unnamed>"
|
name = "<unnamed>"
|
||||||
}
|
}
|
||||||
fmt.Fprintf(out, "Port:\t%s\t%d/%s\n", name, sp.Port, sp.Protocol)
|
fmt.Fprintf(out, "Port:\t%s\t%d/%s\n", name, sp.Port, sp.Protocol)
|
||||||
|
fmt.Fprintf(out, "Endpoints:\t%s\t%s\n", name, formatEndpoints(endpoints, util.NewStringSet(sp.Name)))
|
||||||
}
|
}
|
||||||
fmt.Fprintf(out, "Endpoints:\t%s\n", formatEndpoints(endpoints))
|
|
||||||
fmt.Fprintf(out, "Session Affinity:\t%s\n", service.Spec.SessionAffinity)
|
fmt.Fprintf(out, "Session Affinity:\t%s\n", service.Spec.SessionAffinity)
|
||||||
if events != nil {
|
if events != nil {
|
||||||
DescribeEvents(events, out)
|
DescribeEvents(events, out)
|
||||||
|
|
|
@ -305,7 +305,8 @@ func (h *HumanReadablePrinter) printHeader(columnNames []string, w io.Writer) er
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatEndpoints(endpoints *api.Endpoints) string {
|
// Pass ports=nil for all ports.
|
||||||
|
func formatEndpoints(endpoints *api.Endpoints, ports util.StringSet) string {
|
||||||
if len(endpoints.Subsets) == 0 {
|
if len(endpoints.Subsets) == 0 {
|
||||||
return "<none>"
|
return "<none>"
|
||||||
}
|
}
|
||||||
|
@ -317,7 +318,7 @@ Loop:
|
||||||
ss := &endpoints.Subsets[i]
|
ss := &endpoints.Subsets[i]
|
||||||
for i := range ss.Ports {
|
for i := range ss.Ports {
|
||||||
port := &ss.Ports[i]
|
port := &ss.Ports[i]
|
||||||
if port.Name == "" { // TODO: add multi-port support.
|
if ports == nil || ports.Has(port.Name) {
|
||||||
for i := range ss.Addresses {
|
for i := range ss.Addresses {
|
||||||
if len(list) == max {
|
if len(list) == max {
|
||||||
more = true
|
more = true
|
||||||
|
@ -555,7 +556,7 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func printEndpoints(endpoints *api.Endpoints, w io.Writer) error {
|
func printEndpoints(endpoints *api.Endpoints, w io.Writer) error {
|
||||||
_, err := fmt.Fprintf(w, "%s\t%s\n", endpoints.Name, formatEndpoints(endpoints))
|
_, err := fmt.Fprintf(w, "%s\t%s\n", endpoints.Name, formatEndpoints(endpoints, nil))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue