@@ -22,6 +22,7 @@ import (
2222 "bytes"
2323 "context"
2424 "encoding/json"
25+ "fmt"
2526 "github.com/nginxinc/nginx-k8s-supportpkg/pkg/crds"
2627 "github.com/nginxinc/nginx-k8s-supportpkg/pkg/data_collector"
2728 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -45,12 +46,16 @@ func NICJobList() []Job {
4546 } else {
4647 for _ , pod := range pods .Items {
4748 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+ }
5459 }
5560 }
5661 }
@@ -72,12 +77,15 @@ func NICJobList() []Job {
7277 } else {
7378 for _ , pod := range pods .Items {
7479 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+ }
8189 }
8290 }
8391 }
0 commit comments