Skip to content
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

Add flag for --client to provide path to kubectl #811

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion src/go/pt-k8s-debug-collector/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 if --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
Expand All @@ -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 overridden by --client flag

Known Issues
============
Expand Down
4 changes: 2 additions & 2 deletions src/go/pt-k8s-debug-collector/dumper/dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 3 additions & 1 deletion src/go/pt-k8s-debug-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand Down
Loading