@@ -22,6 +22,7 @@ import (
22
22
"bytes"
23
23
"context"
24
24
"encoding/json"
25
+ "fmt"
25
26
"github.com/nginxinc/nginx-k8s-supportpkg/pkg/crds"
26
27
"github.com/nginxinc/nginx-k8s-supportpkg/pkg/data_collector"
27
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -45,12 +46,16 @@ func NICJobList() []Job {
45
46
} else {
46
47
for _ , pod := range pods .Items {
47
48
if strings .Contains (pod .Name , "ingress" ) {
48
- res , err := dc .PodExecutor (namespace , pod .Name , "nginx-ingress" , command , ctx )
49
- if err != nil {
50
- jobResult .Error = err
51
- dc .Logger .Printf ("\t Command execution %s failed for pod %s in namespace %s: %v\n " , command , pod .Name , namespace , err )
52
- } else {
53
- jobResult .Files [filepath .Join (dc .BaseDir , "exec" , namespace , pod .Name + "__nginx-ingress-version.txt" )] = res
49
+ for _ , container := range pod .Spec .Containers {
50
+
51
+ res , err := dc .PodExecutor (namespace , pod .Name , container .Name , command , ctx )
52
+ if err != nil {
53
+ jobResult .Error = err
54
+ dc .Logger .Printf ("\t Command execution %s failed for pod %s in namespace %s: %v\n " , command , pod .Name , namespace , err )
55
+ } else {
56
+ fileName := fmt .Sprintf ("%s__%s__nginx-ingress-version.txt" , pod .Name , container .Name )
57
+ jobResult .Files [filepath .Join (dc .BaseDir , "exec" , namespace , fileName )] = res
58
+ }
54
59
}
55
60
}
56
61
}
@@ -72,12 +77,15 @@ func NICJobList() []Job {
72
77
} else {
73
78
for _ , pod := range pods .Items {
74
79
if strings .Contains (pod .Name , "ingress" ) {
75
- res , err := dc .PodExecutor (namespace , pod .Name , "nginx-ingress" , command , ctx )
76
- if err != nil {
77
- jobResult .Error = err
78
- dc .Logger .Printf ("\t Command execution %s failed for pod %s in namespace %s: %v\n " , command , pod .Name , namespace , err )
79
- } else {
80
- jobResult .Files [filepath .Join (dc .BaseDir , "exec" , namespace , pod .Name + "__nginx-t.txt" )] = res
80
+ for _ , container := range pod .Spec .Containers {
81
+ res , err := dc .PodExecutor (namespace , pod .Name , container .Name , command , ctx )
82
+ if err != nil {
83
+ jobResult .Error = err
84
+ dc .Logger .Printf ("\t Command execution %s failed for pod %s in namespace %s: %v\n " , command , pod .Name , namespace , err )
85
+ } else {
86
+ fileName := fmt .Sprintf ("%s__%s__nginx-t.txt" , pod .Name , container .Name )
87
+ jobResult .Files [filepath .Join (dc .BaseDir , "exec" , namespace , fileName )] = res
88
+ }
81
89
}
82
90
}
83
91
}
0 commit comments