@@ -214,6 +214,13 @@ func (c *CollectClusterResources) Collect(progressChan chan<- interface{}) (Coll
214214 }
215215 output .SaveResult (c .BundlePath , path .Join (constants .CLUSTER_RESOURCES_DIR , fmt .Sprintf ("%s-errors.json" , constants .CLUSTER_RESOURCES_STATEFULSETS )), marshalErrors (statefulsetsErrors ))
216216
217+ // daemonsets
218+ daemonsets , daemonsetsErrors := daemonsets (ctx , client , namespaceNames )
219+ for k , v := range daemonsets {
220+ output .SaveResult (c .BundlePath , path .Join (constants .CLUSTER_RESOURCES_DIR , constants .CLUSTER_RESOURCES_DAEMONSETS , k ), bytes .NewBuffer (v ))
221+ }
222+ output .SaveResult (c .BundlePath , path .Join (constants .CLUSTER_RESOURCES_DIR , fmt .Sprintf ("%s-errors.json" , constants .CLUSTER_RESOURCES_DAEMONSETS )), marshalErrors (daemonsetsErrors ))
223+
217224 // replicasets
218225 replicasets , replicasetsErrors := replicasets (ctx , client , namespaceNames )
219226 for k , v := range replicasets {
@@ -646,6 +653,42 @@ func statefulsets(ctx context.Context, client *kubernetes.Clientset, namespaces
646653 return statefulsetsByNamespace , errorsByNamespace
647654}
648655
656+ func daemonsets (ctx context.Context , client * kubernetes.Clientset , namespaces []string ) (map [string ][]byte , map [string ]string ) {
657+ daemonsetsByNamespace := make (map [string ][]byte )
658+ errorsByNamespace := make (map [string ]string )
659+
660+ for _ , namespace := range namespaces {
661+ daemonsets , err := client .AppsV1 ().DaemonSets (namespace ).List (ctx , metav1.ListOptions {})
662+
663+ if err != nil {
664+ errorsByNamespace [namespace ] = err .Error ()
665+ continue
666+ }
667+
668+ gvk , err := apiutil .GVKForObject (daemonsets , scheme .Scheme )
669+ if err == nil {
670+ daemonsets .GetObjectKind ().SetGroupVersionKind (gvk )
671+ }
672+
673+ for i , o := range daemonsets .Items {
674+ gvk , err := apiutil .GVKForObject (& o , scheme .Scheme )
675+ if err == nil {
676+ daemonsets .Items [i ].GetObjectKind ().SetGroupVersionKind (gvk )
677+ }
678+ }
679+
680+ b , err := json .MarshalIndent (daemonsets , "" , " " )
681+ if err != nil {
682+ errorsByNamespace [namespace ] = err .Error ()
683+ continue
684+ }
685+
686+ daemonsetsByNamespace [namespace + ".json" ] = b
687+ }
688+
689+ return daemonsetsByNamespace , errorsByNamespace
690+ }
691+
649692func replicasets (ctx context.Context , client * kubernetes.Clientset , namespaces []string ) (map [string ][]byte , map [string ]string ) {
650693 replicasetsByNamespace := make (map [string ][]byte )
651694 errorsByNamespace := make (map [string ]string )
0 commit comments