问题
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.
回答1:
Got it working:
In Windows, you should set environment variable:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/39922430/cant-connect-to-container-cluster-environment-variable-home-or-kubeconfig-must