Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't connect to container cluster: environment variable HOME or KUBECONFIG must be set when running gcloud get credentials

For some reason I can't connect to the cluster. Having followed the instructions per google container-engine after setting up the cluster, I get the following error:

ERROR: (gcloud.container.clusters.get-credentials) environment variable HOME or KUBECONFIG must be set to store credentials for kubectl

When running this command: gcloud container clusters get-credentials [my cluster name] --zone us-central1-b --project [my project name]

Any ideas how I should be setting the variable HOME or KUBECONFIG. I couldn't find anything specific for container-engine.

like image 970
Robert Jackson Avatar asked Oct 07 '16 16:10

Robert Jackson


People also ask

What is Kubeconfig environment variable?

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. If you have a KUBECONFIG environment variable, familiarize yourself with the configuration files in the list.

How do I connect to k8s cluster?

Go client. To get the library, run the following command: go get k8s.io/client-go@kubernetes-<kubernetes-version-number> , see INSTALL.md for detailed installation instructions. See https://github.com/kubernetes/client-go to see which versions are supported. Write an application atop of the client-go clients.

Where is the default Kubeconfig file located in the current environment?

By default, kubectl looks for a file named config in the $HOME/. kube directory. You can specify other kubeconfig files by setting the KUBECONFIG environment variable or by setting the --kubeconfig flag.


1 Answers

Got it working:

In Windows, you should set environment variable: enter image description here

and then creating a folder and a file under current user folder, as the following:

mkdir .kube
cd .kube
echo "" > config

As you make the config file under current user, gcloud should have the right permissions to access the file.

like image 128
Majico Avatar answered Oct 01 '22 15:10

Majico