kubernetes client-go plugin exec command not found on Windows 10
Solution 1:
Kubernetes client-go already have helper methods for authentication using kubeconfig. It contains two variants with good examples:
- Out of cluster authentication example
- In cluster authentication example
I would recommend to use two built-in helper methods instead of rolling a custom variant. You may perhaps want to add an argument so that you can switch between the two, e.g. using out-of-cluster when running locally on Windows and in-cluster when the app (if your code is an app?) is running as a service in the cluster.
Solution 2:
There is little documentation on using kubeconfig under Windows, so with a lot trial and error and a little help from @mdaniel's comment I came up with the following solution:
I created a Windows batch file that contains one line:
@python <path-to-script> %*
and referenced that file with full path in command:
under exec:
.
I had to use %*
because python script takes parameters.
@
prevents Windows from echoing this command in console when running batch.
I couldn't do command: <path-to-python>\python <path-to-script>
because kubernetes still complained it couldn't find the executable with such name.
Also, as a side note, if you use Windows environment variables like %userprofile%
in kubeconfig, they need to be referenced inside single quotes.