mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Show pods number when describing services
This commit is contained in:
parent
6fa2777e26
commit
93669a6bb5
@ -522,7 +522,7 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
|
|||||||
if sp.NodePort != 0 {
|
if sp.NodePort != 0 {
|
||||||
fmt.Fprintf(out, "NodePort:\t%s\t%d/%s\n", name, sp.Port, sp.Protocol)
|
fmt.Fprintf(out, "NodePort:\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, util.NewStringSet(sp.Name)))
|
||||||
}
|
}
|
||||||
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 {
|
||||||
|
@ -317,7 +317,7 @@ func formatEndpoints(endpoints *api.Endpoints, ports util.StringSet) string {
|
|||||||
list := []string{}
|
list := []string{}
|
||||||
max := 3
|
max := 3
|
||||||
more := false
|
more := false
|
||||||
Loop:
|
count := 0
|
||||||
for i := range endpoints.Subsets {
|
for i := range endpoints.Subsets {
|
||||||
ss := &endpoints.Subsets[i]
|
ss := &endpoints.Subsets[i]
|
||||||
for i := range ss.Ports {
|
for i := range ss.Ports {
|
||||||
@ -326,17 +326,19 @@ Loop:
|
|||||||
for i := range ss.Addresses {
|
for i := range ss.Addresses {
|
||||||
if len(list) == max {
|
if len(list) == max {
|
||||||
more = true
|
more = true
|
||||||
break Loop
|
|
||||||
}
|
}
|
||||||
addr := &ss.Addresses[i]
|
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, ",")
|
ret := strings.Join(list, ",")
|
||||||
if more {
|
if more {
|
||||||
ret += "..."
|
return fmt.Sprintf("%s + %d more...", ret, count-max)
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user