From 2dbcc16f4bc6374d92a7092c9988bec2a02f4c60 Mon Sep 17 00:00:00 2001 From: Chetan Shivashankar Date: Mon, 29 Apr 2024 19:05:58 +0530 Subject: [PATCH 1/3] Adding flag for kubectl path --- src/go/pt-k8s-debug-collector/README.rst | 6 +++++- src/go/pt-k8s-debug-collector/dumper/dumper.go | 4 ++-- src/go/pt-k8s-debug-collector/main.go | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/go/pt-k8s-debug-collector/README.rst b/src/go/pt-k8s-debug-collector/README.rst index 6b72ad16f..ae96ef5f4 100644 --- a/src/go/pt-k8s-debug-collector/README.rst +++ b/src/go/pt-k8s-debug-collector/README.rst @@ -157,6 +157,10 @@ Targeted cluster. By default data from all available clusters to be collected Path to kubeconfig. Default configuration be used if none specified +``--client`` + +Path to kubernetes client. Default 'kubectl' is used --client is not set + ``--forwardport`` Port to use when collecting database-specific summaries. By default, 3306 will be used for PXC and MySQL, 27017 for MongoDB, and 5432 for PostgreSQL @@ -168,11 +172,11 @@ Print version info Requirements ============ -- Installed, configured, and available in PATH ``kubectl`` - Installed, configured, and available in PATH ``pt-mysql-summary`` for PXC and MySQL - Installed, configured, and available in PATH ``mysql`` for PXC and MySQL - Installed, configured, and available in PATH ``pt-mongodb-summary`` for MongoDB - Installed, configured, and available in PATH ``psql`` for PostgreSQL +- Installed, configured, and available in PATH kubernetes client like ``kubectl``. Can be overriden by --client flag Known Issues ============ diff --git a/src/go/pt-k8s-debug-collector/dumper/dumper.go b/src/go/pt-k8s-debug-collector/dumper/dumper.go index 73b784d84..2faf3bef3 100644 --- a/src/go/pt-k8s-debug-collector/dumper/dumper.go +++ b/src/go/pt-k8s-debug-collector/dumper/dumper.go @@ -36,9 +36,9 @@ type Dumper struct { var resourcesRe = regexp.MustCompile(`(\w+)\.(\w+).percona\.com`) // New return new Dumper object -func New(location, namespace, resource string, kubeconfig string, forwardport string) Dumper { +func New(location, namespace, resource string, kubeconfig string, client string, forwardport string) Dumper { d := Dumper{ - cmd: "kubectl", + cmd: client, kubeconfig: kubeconfig, location: "cluster-dump", mode: int64(0o777), diff --git a/src/go/pt-k8s-debug-collector/main.go b/src/go/pt-k8s-debug-collector/main.go index db7a8005b..b08e7a894 100644 --- a/src/go/pt-k8s-debug-collector/main.go +++ b/src/go/pt-k8s-debug-collector/main.go @@ -27,11 +27,13 @@ func main() { clusterName := "" kubeconfig := "" forwardport := "" + client := "" version := false flag.StringVar(&namespace, "namespace", "", "Namespace for collecting data. If empty data will be collected from all namespaces") flag.StringVar(&resource, "resource", "auto", "Collect data, specific to the resource. Supported values: pxc, psmdb, pg, pgv2, ps, none, auto") flag.StringVar(&clusterName, "cluster", "", "Cluster name") + flag.StringVar(&client, "client", "kubectl", "Path to kubernetes client like kubectl,oc") flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to kubeconfig") flag.StringVar(&forwardport, "forwardport", "", "Port to use for port forwarding") flag.BoolVar(&version, "version", false, "Print version") @@ -50,7 +52,7 @@ func main() { resource += "/" + clusterName } - d := dumper.New("", namespace, resource, kubeconfig, forwardport) + d := dumper.New("", namespace, resource, kubeconfig, client, forwardport) log.Println("Start collecting cluster data") err := d.DumpCluster() From db562dd28885cf9290c81f8df0dbc1e8bbefc186 Mon Sep 17 00:00:00 2001 From: Chetan Shivashankar Date: Mon, 29 Apr 2024 19:07:01 +0530 Subject: [PATCH 2/3] Readme correction --- src/go/pt-k8s-debug-collector/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/go/pt-k8s-debug-collector/README.rst b/src/go/pt-k8s-debug-collector/README.rst index ae96ef5f4..ed1d329ba 100644 --- a/src/go/pt-k8s-debug-collector/README.rst +++ b/src/go/pt-k8s-debug-collector/README.rst @@ -159,7 +159,7 @@ Path to kubeconfig. Default configuration be used if none specified ``--client`` -Path to kubernetes client. Default 'kubectl' is used --client is not set +Path to kubernetes client. Default 'kubectl' is used if --client is not set ``--forwardport`` From 7a5232ea1fa03dedfdc97ee6505da457d331758d Mon Sep 17 00:00:00 2001 From: Chetan Shivashankar Date: Mon, 29 Apr 2024 19:12:52 +0530 Subject: [PATCH 3/3] Fixing typo --- src/go/pt-k8s-debug-collector/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/go/pt-k8s-debug-collector/README.rst b/src/go/pt-k8s-debug-collector/README.rst index ed1d329ba..16dd040da 100644 --- a/src/go/pt-k8s-debug-collector/README.rst +++ b/src/go/pt-k8s-debug-collector/README.rst @@ -176,7 +176,7 @@ Requirements - Installed, configured, and available in PATH ``mysql`` for PXC and MySQL - Installed, configured, and available in PATH ``pt-mongodb-summary`` for MongoDB - Installed, configured, and available in PATH ``psql`` for PostgreSQL -- Installed, configured, and available in PATH kubernetes client like ``kubectl``. Can be overriden by --client flag +- Installed, configured, and available in PATH kubernetes client like ``kubectl``. Can be overridden by --client flag Known Issues ============