mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-02-14 18:29:53 +00:00
Add Daemonset collection to cluster_resources (#1213)
* added daemonset collection to cluster_resources * squash commit to remove commit that was submitted by root
This commit is contained in:
@@ -214,6 +214,13 @@ func (c *CollectClusterResources) Collect(progressChan chan<- interface{}) (Coll
|
||||
}
|
||||
output.SaveResult(c.BundlePath, path.Join(constants.CLUSTER_RESOURCES_DIR, fmt.Sprintf("%s-errors.json", constants.CLUSTER_RESOURCES_STATEFULSETS)), marshalErrors(statefulsetsErrors))
|
||||
|
||||
// daemonsets
|
||||
daemonsets, daemonsetsErrors := daemonsets(ctx, client, namespaceNames)
|
||||
for k, v := range daemonsets {
|
||||
output.SaveResult(c.BundlePath, path.Join(constants.CLUSTER_RESOURCES_DIR, constants.CLUSTER_RESOURCES_DAEMONSETS, k), bytes.NewBuffer(v))
|
||||
}
|
||||
output.SaveResult(c.BundlePath, path.Join(constants.CLUSTER_RESOURCES_DIR, fmt.Sprintf("%s-errors.json", constants.CLUSTER_RESOURCES_DAEMONSETS)), marshalErrors(daemonsetsErrors))
|
||||
|
||||
// replicasets
|
||||
replicasets, replicasetsErrors := replicasets(ctx, client, namespaceNames)
|
||||
for k, v := range replicasets {
|
||||
@@ -646,6 +653,42 @@ func statefulsets(ctx context.Context, client *kubernetes.Clientset, namespaces
|
||||
return statefulsetsByNamespace, errorsByNamespace
|
||||
}
|
||||
|
||||
func daemonsets(ctx context.Context, client *kubernetes.Clientset, namespaces []string) (map[string][]byte, map[string]string) {
|
||||
daemonsetsByNamespace := make(map[string][]byte)
|
||||
errorsByNamespace := make(map[string]string)
|
||||
|
||||
for _, namespace := range namespaces {
|
||||
daemonsets, err := client.AppsV1().DaemonSets(namespace).List(ctx, metav1.ListOptions{})
|
||||
|
||||
if err != nil {
|
||||
errorsByNamespace[namespace] = err.Error()
|
||||
continue
|
||||
}
|
||||
|
||||
gvk, err := apiutil.GVKForObject(daemonsets, scheme.Scheme)
|
||||
if err == nil {
|
||||
daemonsets.GetObjectKind().SetGroupVersionKind(gvk)
|
||||
}
|
||||
|
||||
for i, o := range daemonsets.Items {
|
||||
gvk, err := apiutil.GVKForObject(&o, scheme.Scheme)
|
||||
if err == nil {
|
||||
daemonsets.Items[i].GetObjectKind().SetGroupVersionKind(gvk)
|
||||
}
|
||||
}
|
||||
|
||||
b, err := json.MarshalIndent(daemonsets, "", " ")
|
||||
if err != nil {
|
||||
errorsByNamespace[namespace] = err.Error()
|
||||
continue
|
||||
}
|
||||
|
||||
daemonsetsByNamespace[namespace+".json"] = b
|
||||
}
|
||||
|
||||
return daemonsetsByNamespace, errorsByNamespace
|
||||
}
|
||||
|
||||
func replicasets(ctx context.Context, client *kubernetes.Clientset, namespaces []string) (map[string][]byte, map[string]string) {
|
||||
replicasetsByNamespace := make(map[string][]byte)
|
||||
errorsByNamespace := make(map[string]string)
|
||||
|
||||
@@ -30,6 +30,7 @@ const (
|
||||
CLUSTER_RESOURCES_DEPLOYMENTS = "deployments"
|
||||
CLUSTER_RESOURCES_REPLICASETS = "replicasets"
|
||||
CLUSTER_RESOURCES_STATEFULSETS = "statefulsets"
|
||||
CLUSTER_RESOURCES_DAEMONSETS = "daemonsets"
|
||||
CLUSTER_RESOURCES_JOBS = "jobs"
|
||||
CLUSTER_RESOURCES_CRONJOBS = "cronjobs"
|
||||
CLUSTER_RESOURCES_INGRESS = "ingress"
|
||||
|
||||
Reference in New Issue
Block a user