Skip to content

Commit 0e3bcd2

Browse files
committed
Add nodes to the bundle
1 parent 2a3e4e7 commit 0e3bcd2

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

examples/troubleshoot/sample-troubleshoot.yaml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,4 @@ kind: Collector
33
metadata:
44
name: collector-sample
55
spec:
6-
collectors:
7-
- secret:
8-
name: myapp-postgres
9-
namespace: default
10-
key: uri
11-
includeValue: false
12-
- logs:
13-
selector:
14-
- name=cilium-operator
15-
namespace: kube-system
16-
limits:
17-
maxAge: 30d
18-
maxLines: 10000
19-
- run:
20-
collectorName: ping-google
21-
namespace: default
22-
image: flungo/netutils
23-
command: ["ping"]
24-
args: ["www.google.com"]
25-
timeout: 5s
26-
- http:
27-
collectorName: echo-ip
28-
get:
29-
url: https://api.replicated.com/market/v1/echo/ip
6+
collectors: []

pkg/collect/cluster_resources.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ type ClusterResourcesOutput struct {
3030
CustomResourceDefinitionsErrors []byte `json:"cluster-resources/custom-resource-definitions-errors.json,omitempty"`
3131
ImagePullSecrets map[string][]byte `json:"cluster-resources/image-pull-secrets,omitempty"`
3232
ImagePullSecretsErrors []byte `json:"cluster-resources/image-pull-secrets-errors.json,omitempty"`
33+
Nodes []byte `json:"cluster-resources/nodes.json,omitempty"`
34+
NodesErrors []byte `json:"cluster-resources/nodes-errors.json,omitempty"`
3335
}
3436

3537
func ClusterResources(ctx *Context) ([]byte, error) {
@@ -113,6 +115,14 @@ func ClusterResources(ctx *Context) ([]byte, error) {
113115
return nil, err
114116
}
115117

118+
// nodes
119+
nodes, nodeErrors := nodes(client)
120+
clusterResourcesOutput.Nodes = nodes
121+
clusterResourcesOutput.NodesErrors, err = marshalNonNil(nodeErrors)
122+
if err != nil {
123+
return nil, err
124+
}
125+
116126
if ctx.Redact {
117127
clusterResourcesOutput, err = clusterResourcesOutput.Redact()
118128
if err != nil {
@@ -314,11 +324,29 @@ func imagePullSecrets(client *kubernetes.Clientset, namespaces []string) (map[st
314324
return imagePullSecrets, errors
315325
}
316326

327+
func nodes(client *kubernetes.Clientset) ([]byte, []string) {
328+
nodes, err := client.CoreV1().Nodes().List(metav1.ListOptions{})
329+
if err != nil {
330+
return nil, []string{err.Error()}
331+
}
332+
333+
b, err := json.MarshalIndent(nodes.Items, "", " ")
334+
if err != nil {
335+
return nil, []string{err.Error()}
336+
}
337+
338+
return b, nil
339+
}
340+
317341
func (c *ClusterResourcesOutput) Redact() (*ClusterResourcesOutput, error) {
318342
namespaces, err := redact.Redact(c.Namespaces)
319343
if err != nil {
320344
return nil, err
321345
}
346+
nodes, err := redact.Redact(c.Nodes)
347+
if err != nil {
348+
return nil, err
349+
}
322350
pods, err := redactMap(c.Pods)
323351
if err != nil {
324352
return nil, err
@@ -346,6 +374,8 @@ func (c *ClusterResourcesOutput) Redact() (*ClusterResourcesOutput, error) {
346374
return &ClusterResourcesOutput{
347375
Namespaces: namespaces,
348376
NamespacesErrors: c.NamespacesErrors,
377+
Nodes: nodes,
378+
NodesErrors: c.NodesErrors,
349379
Pods: pods,
350380
PodsErrors: c.PodsErrors,
351381
Services: services,

0 commit comments

Comments
 (0)