mirror of https://github.com/k3s-io/k3s
Merge pull request #8778 from kargakis/show-pod-number
Show pods number when describing servicespull/6/head
commit
32859c3954
|
@ -522,7 +522,7 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
|
|||
if sp.NodePort != 0 {
|
||||
fmt.Fprintf(out, "NodePort:\t%s\t%d/%s\n", name, sp.NodePort, 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, util.NewStringSet(sp.Name)))
|
||||
}
|
||||
fmt.Fprintf(out, "Session Affinity:\t%s\n", service.Spec.SessionAffinity)
|
||||
if events != nil {
|
||||
|
|
|
@ -317,7 +317,7 @@ func formatEndpoints(endpoints *api.Endpoints, ports util.StringSet) string {
|
|||
list := []string{}
|
||||
max := 3
|
||||
more := false
|
||||
Loop:
|
||||
count := 0
|
||||
for i := range endpoints.Subsets {
|
||||
ss := &endpoints.Subsets[i]
|
||||
for i := range ss.Ports {
|
||||
|
@ -326,17 +326,19 @@ Loop:
|
|||
for i := range ss.Addresses {
|
||||
if len(list) == max {
|
||||
more = true
|
||||
break Loop
|
||||
}
|
||||
addr := &ss.Addresses[i]
|
||||
list = append(list, fmt.Sprintf("%s:%d", addr.IP, port.Port))
|
||||
if !more {
|
||||
list = append(list, fmt.Sprintf("%s:%d", addr.IP, port.Port))
|
||||
}
|
||||
count++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ret := strings.Join(list, ",")
|
||||
if more {
|
||||
ret += "..."
|
||||
return fmt.Sprintf("%s + %d more...", ret, count-max)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue