Why does "kubectl" in a cygwin shell ignore KUBECONFIG, but Go apps using same api work fine?
KARR, DAVID
dk068x@att.com
Thu Jun 26 22:23:43 GMT 2025
I'm seeing something subtly off in my Cygwin shells that I can't quite figure out. Some of these details are probably irrelevant to Cygwin, but I can't tell.
I use "kubectl" to connect to the control plane for a number of Kubernetes clusters. I also have a few Go applications I've built myself that use the same Kubernetes-client api that "kubectl" uses.
By default, "kubectl" looks for a config file at "~/.kube/config" (paraphrasing path syntax). So far, everything works fine.
Kubectl can also look for a "KUBECONFIG" environment variable, which should have a "pathlist" value, listing the files to use instead of the default "~/.kube/config". I had a reason to want to use two separate files, so I implemented this, resulting in files named "users" and "allbutusers". As I'm on Windows, and kubectl is a Windows application, not Cygwin, I set KUBECONFIG at the Windows level to this:
c:\Users\<userid>\.kube\allbutusers;C:\Users\<userid>\.kube\users
I then renamed "config" in that directory to "config.bak". I rebooted, just to make sure everything was consistent.
In a Windows cmd shell, I verified that both "kubectl" and my custom apps work fine.
In a Cygwin shell, I verified that my custom apps work fine.
However, in a Cygwin shell, "kubectl" now fails with:
error: CreateFile C:\cygwin64\home\<userid>\.kube\config: The file cannot be accessed by the system.
Note that this is referring to my Cygwin HOME, not Windows home, which are different locations. In my Cygwin home, the ".kube" directory is a symlink to my Windows home, but I'm guessing kubectl, being a non-cygwin app, can't see that.
Looking at the error I'm getting, I would think that my custom Go apps would fail the same way, but they don't. I've looked at my Go code that reads the environment variable, and I've looked at the Go library code that looks for this environment variable, and they are doing basically the same thing.
More information about the Cygwin
mailing list