question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error loading config file

See original GitHub issue

Problem

The extension is spewing out the following error (appears to be around once every minute):

error: Error loading config file "/home/d4nyll/.kube/config": read /home/d4nyll/.kube/config: is a directory

It is throwing the error because /home/d4nyll/.kube/config is a directory, and not a configuration file. However, this should not be an error because Kubernetes allows the configuration files to be split into multiple files. Indeed, from the documentation:

The KUBECONFIG environment variable is a list of paths to configuration files. The list is colon-delimited for Linux and Mac, and semicolon-delimited for Windows.

I have set up my KUBECONFIG environment variable to be a colon-separated list.

$ echo $KUBECONFIG | tr ':' '\n'
/home/d4nyll/.kube/config/k8s-dev
/home/d4nyll/.kube/config/k8s-admin
/home/d4nyll/.kube/config/minikube
/home/d4nyll/.kube/config/do-lon1-ghost
/home/d4nyll/.kube/config/do-lon1-bud

$ node
Welcome to Node.js v12.5.0.
> console.log(process.env.KUBECONFIG.replace(/:/g, "\n"));
/home/d4nyll/.kube/config/k8s-dev
/home/d4nyll/.kube/config/k8s-admin
/home/d4nyll/.kube/config/minikube
/home/d4nyll/.kube/config/do-lon1-ghost
/home/d4nyll/.kube/config/do-lon1-bud

Solution

  • Check process.env.KUBECONFIG before using the default of $HOME/.kube/config
  • Merge the configuration files together

Proposal

N.B. I haven’t read the entire codebase in detail, so this may be the wrong place to implement it. Advice welcomed.

Right now, the configuration is first read from the workspace configuration.

export function getActiveKubeconfig(): string {
    return vscode.workspace.getConfiguration(EXTENSION_CONFIG_KEY)[KUBECONFIG_PATH_KEY];
}

If this is not found, then it will try to read from a default path

function getDefaultKubeconfig(): string {
    return path.join((process.env['HOME'] || process.env['USERPROFILE'] || '.'), ".kube", "config");
}

I propose to add an additional check to kubeconfigPath() to also check the environment variable KUBECONFIG and read and merge all those files together as one before passing the configuration object to downstream functions.

function kubeconfigPath(): string {
    return getActiveKubeconfig() || getEnvKubeConfig() || getDefaultKubeconfig();
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
itowlsoncommented, Sep 11, 2019

Yes, loadFromDefault probably makes more sense (unless the user has set a non-default kubeconfig in their VS Code settings). And I should dig into that to see how it handles the multi-file case so we can support that in the settings override case. Thanks!

I’m travelling at the moment, but will hopefully get to this in a couple of weeks when I get back. Sorry for the delay, and thanks for all the digging.

0reactions
itowlsoncommented, Oct 1, 2019

Oh no! Thank you for closing the loop on this one - I’m almost disappointed that it turned out to be a configuration error at your end - it would have been a very satisfying bug to fix! But having it working for you is the most important thing!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error loading config file | Filebeat Reference [8.5] - Elastic
Error loading config fileedit​​ You may encounter errors loading the config file on POSIX operating systems if: an unauthorized user tries to load...
Read more >
Error loading config file · Issue #610 · vscode-kubernetes-tools ...
It is throwing the error because /home/d4nyll/.kube/config is a directory, and not a configuration file. However, this should not be an ...
Read more >
Articles in this section - Codefresh
Symptoms. Pipeline is failed with following error: loading config file "/codefresh/volume/sensitive/.kube/config": v1.Config.Contexts: []v1.
Read more >
0 - Stack Overflow
I have manually set up the KUBECONFIG file in /var/lib/jenkins/.kube/config . But my Jenkins job keeps giving the same error: + kubectl config ......
Read more >
Error loading config file: java.net.UnknownHostException ...
There is an SSL communication failure on the server. Traces (such as XPI Inspector or the Troubleshooting Wizard) contain a similar error: Error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found