Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does gcloud store its defaults?

Following this Quickstart I set a default project like this

$ gcloud config set project lfs258 Updated property [core/project]. $ gcloud config get-value project lfs258 

The project lfs258 doesn't exist on my GCP account, though, so I'm surprised that I could set it as the default. When I try to see where gcloud stores its defaults there is no .gcloud/ directory.

Where does gcloud store its defaults? kubectl stores them in .kube/config but I can't find a similar config file for gcloud.

like image 918
Dean Schulze Avatar asked Mar 10 '18 18:03

Dean Schulze


People also ask

Where is my gcloud credentials stored?

Your credentials are stored at ~/. config/gcloud . Credentials are stored in two files: access_tokens. db and credentials.

How do I change default GCP resource location?

After you set your project's default GCP resource location, you cannot change it. Note that your default GCP resource location only applies to your default Cloud Storage bucket. You can create multiple buckets, each with their own location.

What is gcloud Auth Application default?

gcloud auth login asks you to choose an account to continue to give access to 'google cloud sdk'. gcloud auth application-default login asks you to give access to google auth library instead.


2 Answers

To be more specific gcloud supports multiple configurations. Run

gcloud config configurations list 

to see full list.

If user did not create configuration explicitly he/she gets configuartion named default, and as a result properties set via

gcloud config set ... 

command will get stored in

~/.config/gcloud/configurations/config_default 

If you create new configuration

gcloud config configurations create my_settings 

then properties will be stored in

~/.config/gcloud/configurations/config_my_settings 

Note as a user you should not care where they are stored, and if you need to programatically access them a better option is to run

gcloud config list --format=json 

you can even access specific configuration (not just currently selected) by doing

gcloud config list --format=json --configuration=my_setting 
like image 103
cherba Avatar answered Nov 11 '22 21:11

cherba


To be more generic, you can always run gcloud info to print out a bunch of diagnostics information to display all the configuration files and locations as well as logs and much more. Below is the gcloud info output on my environment, as you can see the configuration files are in User Config Directory: section.

$ 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: [[email protected]] Project: [foo-bar]  Current Properties:   [core]     project: [foo-bar]     account: [[email protected]]     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] 

In this particular case, you can run gcloud info | grep 'User Config' to list the location of the config files, regardless if you custom install it or not.

like image 39
Devy Avatar answered Nov 11 '22 19:11

Devy