krisnova / naml

Convert Kubernetes YAML to Golang
Apache License 2.0
1.26k stars 38 forks source link

not installing with different kubeconfig file #35

Closed Piotr1215 closed 3 years ago

Piotr1215 commented 3 years ago

Hi, really fun project, enjoying it so far :). One little thing I noticed; when I merge 2 kubeconfig files in the KUBECONFIG variable, there is hardcoded path searching for config file in .kube dir in this function in client.go

// Client is used to authenticate with Kubernetes and build the Kube client
// for the rest of the program.
func Client() (*kubernetes.Clientset, error) {
    kubeConfigPath := path.Join(homedir.HomeDir(), ".kube", "config")
    return ClientFromPath(kubeConfigPath)
}

giving this error when context is in other file than config:

unable to find local kube config [/home/decoder/.kube/config]: invalid configuration: [context was not found for specified context: default, cluster has no server defined]

Swapping to another cluster (with context present in config) works as expected.

Maybe reading KUBECONFIG variable on a retry when this error occurs would be a good idea?

krisnova commented 3 years ago

i think the program should inherit the same logic that kubectl uses.

if anyone wants to PR the changes feel free to - otherwise i won't be able to get to them until next week.

cheers

krisnova commented 3 years ago

if you want to try the 0.2.0 release and report back please let us know 🎉

Piotr1215 commented 3 years ago

Thanks for making the change so quickly. I have tested it and although both files are now picked up, the config cannot be loaded.

You can see below, I'm running the setup against docker desktop and than against my vm, both fail with the same error message. Maybe it's worth pointing out that I'm using WLS2, not sure if this might be an issue.

image