cyberark / kubeletctl

A client for kubelet
Apache License 2.0
713 stars 81 forks source link

Use server address from KUBECONFIG #7

Closed zmedico closed 3 years ago

zmedico commented 4 years ago

If a server address is provided by KUBECONFIG, then use it. Meanwhile, allow --server, --port, and --http flags to override relevant portions of the server address provided by KUBECONFIG. Send messages about KUBECONFIG to stderr, so that they do not corrupt --raw json output.

g3rzi commented 4 years ago

Thanks @zmedico I will go over and it and test and update once done. Thanks again for your contribution :)

g3rzi commented 3 years ago

When I tried to use it with a specific server IP, it first go a kubeconfig file I have on the computer although I specified the -s switch and I get errors:

C:\tmp>kubeletctl_windows_amd64.exe -s 123.123.123.123 version
[*] Using KUBECONFIG environment variable
2020/09/10 14:08:59 tls: failed to find any PEM data in certificate input

We need to add another check for the server flag ServerIpAddressFlag in https://github.com/cyberark/kubeletctl/blob/e2bfb8910c317af19e5ec090559cc229bb751b30/cmd/root.go#L127

Another, I didn't on solution for this yet but if I want to check the version of the tool it first try to check for the kubeconfig file but the version command should be able to run in any case. The problem is that the version command is a command and not a switch and therefore I don't see how we can check if it was specificed in initConfig(), maybe there is a way to check what commands where chosen when the program enters the initConig().

C:\tmp>kubeletctl_windows_amd64.exe version
[*] Using KUBECONFIG environment variable
2020/09/10 14:08:25 tls: failed to find any PEM data in certificate input