@@ -352,6 +352,13 @@ func (c *CollectClusterResources) Collect(progressChan chan<- interface{}) (Coll
352352 output .SaveResult (c .BundlePath , path .Join (constants .CLUSTER_RESOURCES_DIR , fmt .Sprintf ("%s.json" , constants .CLUSTER_RESOURCES_CLUSTER_ROLE_BINDINGS )), bytes .NewBuffer (clusterRoleBindings ))
353353 output .SaveResult (c .BundlePath , path .Join (constants .CLUSTER_RESOURCES_DIR , fmt .Sprintf ("%s-errors.json" , constants .CLUSTER_RESOURCES_CLUSTER_ROLE_BINDINGS )), marshalErrors (clusterRoleBindingsErrors ))
354354
355+ // endpoints
356+ endpoints , endpointsErrors := endpoints (ctx , client , namespaceNames )
357+ for k , v := range endpoints {
358+ output .SaveResult (c .BundlePath , path .Join (constants .CLUSTER_RESOURCES_DIR , constants .CLUSTER_RESOURCES_ENDPOINTS , k ), bytes .NewBuffer (v ))
359+ }
360+ output .SaveResult (c .BundlePath , path .Join (constants .CLUSTER_RESOURCES_DIR , fmt .Sprintf ("%s-errors.json" , constants .CLUSTER_RESOURCES_ENDPOINTS )), marshalErrors (endpointsErrors ))
361+
355362 return output , nil
356363}
357364
@@ -1888,3 +1895,38 @@ func clusterRoleBindings(ctx context.Context, client *kubernetes.Clientset) ([]b
18881895 }
18891896 return b , nil
18901897}
1898+
1899+ func endpoints (ctx context.Context , client * kubernetes.Clientset , namespaces []string ) (map [string ][]byte , map [string ]string ) {
1900+ endpointsByNamespace := make (map [string ][]byte )
1901+ errorsByNamespace := make (map [string ]string )
1902+
1903+ for _ , namespace := range namespaces {
1904+ endpoints , err := client .CoreV1 ().Endpoints (namespace ).List (ctx , metav1.ListOptions {})
1905+ if err != nil {
1906+ errorsByNamespace [namespace ] = err .Error ()
1907+ continue
1908+ }
1909+
1910+ gvk , err := apiutil .GVKForObject (endpoints , scheme .Scheme )
1911+ if err == nil {
1912+ endpoints .GetObjectKind ().SetGroupVersionKind (gvk )
1913+ }
1914+
1915+ for i , o := range endpoints .Items {
1916+ gvk , err := apiutil .GVKForObject (& o , scheme .Scheme )
1917+ if err == nil {
1918+ endpoints .Items [i ].GetObjectKind ().SetGroupVersionKind (gvk )
1919+ }
1920+ }
1921+
1922+ b , err := json .MarshalIndent (endpoints , "" , " " )
1923+ if err != nil {
1924+ errorsByNamespace [namespace ] = err .Error ()
1925+ continue
1926+ }
1927+
1928+ endpointsByNamespace [namespace + ".json" ] = b
1929+ }
1930+
1931+ return endpointsByNamespace , errorsByNamespace
1932+ }
0 commit comments