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

大憨熊 提交于 2021-02-07 14:28:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!