mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Show pods number when describing services
This commit is contained in:
		@@ -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.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)
 | 
			
		||||
		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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user