Skip to content

Commit 0886787

Browse files
committed
Issue 36: Add support for NGF - NGINX Gateway Fabric
* Split jobs in common, nic and ngf specific ones * Split CRD list into nic and ngf specific ones * Modified PodExecutor to execute command on a target container
1 parent e168617 commit 0886787

File tree

6 files changed

+571
-394
lines changed

6 files changed

+571
-394
lines changed

cmd/nginx-supportpkg.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/nginxinc/nginx-k8s-supportpkg/pkg/version"
2626
"github.com/spf13/cobra"
2727
"os"
28+
"slices"
2829
)
2930

3031
func Execute() {
@@ -50,7 +51,9 @@ func Execute() {
5051

5152
switch product {
5253
case "nic":
53-
jobList = jobs.NICJobList()
54+
jobList = slices.Concat(jobs.CommonJobList(), jobs.NICJobList())
55+
case "ngf":
56+
jobList = slices.Concat(jobs.CommonJobList(), jobs.NGFJobList())
5457
default:
5558
fmt.Printf("Error: product must be in the following list: [nic]\n")
5659
os.Exit(1)

pkg/crds/crd.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Crd struct {
2424
Version string
2525
}
2626

27-
func GetCRDList() []Crd {
27+
func GetNICCRDList() []Crd {
2828
crdList := []Crd{
2929
{
3030
Resource: "apdoslogconfs",
@@ -84,3 +84,29 @@ func GetCRDList() []Crd {
8484
}
8585
return crdList
8686
}
87+
88+
func GetNGFCRDList() []Crd {
89+
crdList := []Crd{
90+
{
91+
Resource: "clientsettingspolicies",
92+
Group: "gateway.nginx.org",
93+
Version: "v1alpha1",
94+
},
95+
{
96+
Resource: "nginxgateways",
97+
Group: "gateway.nginx.org",
98+
Version: "v1alpha1",
99+
},
100+
{
101+
Resource: "nginxproxies",
102+
Group: "gateway.nginx.org",
103+
Version: "v1alpha1",
104+
},
105+
{
106+
Resource: "observabilitypolicies",
107+
Group: "gateway.nginx.org",
108+
Version: "v1alpha1",
109+
},
110+
}
111+
return crdList
112+
}

pkg/data_collector/data_collector.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,19 @@ func (c *DataCollector) WrapUp(product string) (string, error) {
199199
return tarballName, nil
200200
}
201201

202-
func (c *DataCollector) PodExecutor(namespace string, pod string, command []string, ctx context.Context) ([]byte, error) {
202+
func (c *DataCollector) PodExecutor(namespace string, pod string, container string, command []string, ctx context.Context) ([]byte, error) {
203203
req := c.K8sCoreClientSet.CoreV1().RESTClient().Post().
204204
Namespace(namespace).
205205
Resource("pods").
206206
Name(pod).
207207
SubResource("exec").
208208
VersionedParams(&corev1.PodExecOptions{
209-
Command: command,
210-
Stdin: false,
211-
Stdout: true,
212-
Stderr: true,
213-
TTY: true,
209+
Command: command,
210+
Container: container,
211+
Stdin: false,
212+
Stdout: true,
213+
Stderr: true,
214+
TTY: true,
214215
}, scheme.ParameterCodec)
215216

216217
exec, err := remotecommand.NewSPDYExecutor(c.K8sRestConfig, "POST", req.URL())
@@ -240,7 +241,7 @@ func (c *DataCollector) QueryCRD(crd crds.Crd, namespace string, ctx context.Con
240241
c.K8sRestConfig.NegotiatedSerializer = negotiatedSerializer
241242

242243
client, err := rest.RESTClientFor(c.K8sRestConfig)
243-
244+
c.Logger.Printf("MRAJAGOPAL: %v", err)
244245
if err != nil {
245246
return nil, err
246247
}

0 commit comments

Comments
 (0)