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

10/7/2016

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.

-- Robert Jackson
google-kubernetes-engine
kubectl

2 Answers

6/21/2017

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.

-- Majico
Source: StackOverflow

10/10/2016

gcloud attempts to write a kubeconfig file to $HOME/.kube/config (or $KUBECONFIG if it is set). The most straightforward approach is to set HOME to your home directory, but if you have a reason that you'd like to store your kubectl configuration elsewhere, you can do that with the KUBECONFIG variable.

-- CJ Cullen
Source: StackOverflow