关注this Quickstart我设置了一个像这样的默认项目
$ gcloud config set project lfs258
Updated property [core/project].
$ gcloud config get-value project
lfs258
项目lfs258并不存在于我的GCP帐户中,所以我很惊讶我可以将其设置为默认值。当我试图查看gcloud存储其默认值的位置时,没有.gcloud/
目录。
gcloud在哪里存储默认值? kubectl
将它们存储在.kube/config
中,但我无法为gcloud找到类似的配置文件。
答案 0 :(得分:3)
更具体gcloud
支持多种配置。运行
gcloud config configurations list
查看完整列表。
如果用户未明确创建配置,则他/她将获得名为default
的配置,并且作为结果通过
gcloud config set ...
命令将存储在
中~/.config/gcloud/configurations/config_default
如果您创建新配置
gcloud config configurations create my_settings
然后属性将存储在
中~/.config/gcloud/configurations/config_my_settings
请注意,作为用户,您不应该关心它们的存储位置,如果您需要以编程方式访问它们,则可以选择运行
gcloud config list --format=json
您甚至可以通过
访问特定配置(不仅仅是当前选择的配置)gcloud config list --format=json --configuration=my_setting
答案 1 :(得分:2)
它存储在~/.config/gcloud/configurations/config_default
答案 2 :(得分:1)
要更加通用,您始终可以运行gcloud info
以打印出一系列诊断信息,以显示所有配置文件和位置以及日志等。以下是我的环境中的gcloud info
输出,如您所见,配置文件位于
用户配置目录:部分。
$ gcloud info
Google Cloud SDK [239.0.0]
Platform: [Mac OS X, x86_64] ('Darwin', 'foorbar.local', '18.2.0', 'Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64', 'x86_64', 'i386')
Python Version: [2.7.15 (default, Nov 27 2018, 21:40:55) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)]]
Python Location: [/usr/local/opt/python@2/bin/python2.7]
Site Packages: [Enabled]
Installation Root: [/Users/devy/.google-cloud-sdk]
Installed Components:
kubectl: [2019.03.17]
core: [2019.03.17]
gcloud: []
docker-credential-gcr: []
gsutil: [4.37]
bq: [2.0.42]
alpha: [2019.02.22]
System PATH: [REDACTED]
Python PATH: [REDACTED]
Cloud SDK on PATH: [True]
Kubectl on PATH: [/usr/local/bin/kubectl]
Installation Properties: [/Users/devy/.google-cloud-sdk/properties]
User Config Directory: [/Users/devy/.config/gcloud]
Active Configuration Name: [default]
Active Configuration Path: [/Users/devy/.config/gcloud/configurations/config_default]
Account: [devy@foobar.com]
Project: [foo-bar]
Current Properties:
[core]
project: [foo-bar]
account: [devy@foobar.com]
disable_usage_reporting: [True]
[container]
cluster: [foobar]
[compute]
region: [us-central1]
zone: [us-central1-a]
Logs Directory: [/Users/devy/.config/gcloud/logs]
Last Log File: [/Users/devy/.config/gcloud/logs/2019.03.19/16.39.09.777341.log]
git: [git version 2.19.1]
ssh: [OpenSSH_7.9p1, LibreSSL 2.7.3]
在这种情况下,无论是否自定义安装,您都可以运行gcloud info | grep 'User Config'
列出配置文件的位置。