Skip to content

Issue 36: Add support for NGF - NGINX Gateway Fabric #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions cmd/nginx-supportpkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/nginxinc/nginx-k8s-supportpkg/pkg/version"
"github.com/spf13/cobra"
"os"
"slices"
)

func Execute() {
Expand All @@ -50,9 +51,11 @@ func Execute() {

switch product {
case "nic":
jobList = jobs.NICJobList()
jobList = slices.Concat(jobs.CommonJobList(), jobs.NICJobList())
case "ngf":
jobList = slices.Concat(jobs.CommonJobList(), jobs.NGFJobList())
default:
fmt.Printf("Error: product must be in the following list: [nic]\n")
fmt.Printf("Error: product must be in the following list: [nic, ngf]\n")
os.Exit(1)
}

Expand Down Expand Up @@ -101,8 +104,8 @@ func Execute() {
"Usage:" +
"\n nginx-supportpkg -h|--help" +
"\n nginx-supportpkg -v|--version" +
"\n nginx-supportpkg [-n|--namespace] ns1 [-n|--namespace] ns2 [-p|--product] nic" +
"\n nginx-supportpkg [-n|--namespace] ns1,ns2 [-p|--product] nic \n")
"\n nginx-supportpkg [-n|--namespace] ns1 [-n|--namespace] ns2 [-p|--product] [nic,ngf]" +
"\n nginx-supportpkg [-n|--namespace] ns1,ns2 [-p|--product] [nic,ngf] \n")

if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
Expand Down
28 changes: 27 additions & 1 deletion pkg/crds/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Crd struct {
Version string
}

func GetCRDList() []Crd {
func GetNICCRDList() []Crd {
crdList := []Crd{
{
Resource: "apdoslogconfs",
Expand Down Expand Up @@ -84,3 +84,29 @@ func GetCRDList() []Crd {
}
return crdList
}

func GetNGFCRDList() []Crd {
crdList := []Crd{
{
Resource: "clientsettingspolicies",
Group: "gateway.nginx.org",
Version: "v1alpha1",
},
{
Resource: "nginxgateways",
Group: "gateway.nginx.org",
Version: "v1alpha1",
},
{
Resource: "nginxproxies",
Group: "gateway.nginx.org",
Version: "v1alpha1",
},
{
Resource: "observabilitypolicies",
Group: "gateway.nginx.org",
Version: "v1alpha1",
},
}
return crdList
}
14 changes: 7 additions & 7 deletions pkg/data_collector/data_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,19 @@ func (c *DataCollector) WrapUp(product string) (string, error) {
return tarballName, nil
}

func (c *DataCollector) PodExecutor(namespace string, pod string, command []string, ctx context.Context) ([]byte, error) {
func (c *DataCollector) PodExecutor(namespace string, pod string, container string, command []string, ctx context.Context) ([]byte, error) {
req := c.K8sCoreClientSet.CoreV1().RESTClient().Post().
Namespace(namespace).
Resource("pods").
Name(pod).
SubResource("exec").
VersionedParams(&corev1.PodExecOptions{
Command: command,
Stdin: false,
Stdout: true,
Stderr: true,
TTY: true,
Command: command,
Container: container,
Stdin: false,
Stdout: true,
Stderr: true,
TTY: true,
}, scheme.ParameterCodec)

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

client, err := rest.RESTClientFor(c.K8sRestConfig)

if err != nil {
return nil, err
}
Expand Down
Loading