GCP/gcloud cli

From Ever changing code


Install gcloud cli

# Add the Cloud SDK distribution URI as a package source
echo "deb [signed-by=/usr/share/keyrings/] cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

# Import the Google Cloud Platform public key
curl | sudo apt-key --keyring /usr/share/keyrings/ add -

# Update the package list and install the Cloud SDK
sudo apt-get update && sudo apt-get install google-cloud-sdk


$ gcloud init
Welcome! This command will take you through the configuration of gcloud.

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.                                                                                                                                                                                                                                     
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

You must log in to continue. Would you like to log in (Y/n)?  y

Go to the following link in your browser:

Enter verification code: *****

To take a quick anonymous survey, run:
  $ gcloud alpha survey

You are logged in as: [].

Pick cloud project to use: 
 [1] responsive-sun-123456
 [2] Create a new project
Please enter numeric choice or text value (must exactly match list 
item):  1

Your current project has been set to: [responsive-sun-123456].

Not setting default zone/region (this feature makes it easier to use
[gcloud compute] by setting an appropriate default value for the
--zone and --region flag).
See section on how to set
default compute region and zone manually. If you would like [gcloud init] to be
able to do this for you the next time you run it, make sure the
Compute Engine API is enabled for your project on the page.

Created a default .boto configuration file at [/home/vagrant/.boto]. See this file and
[] for more
information about configuring Google Cloud Storage.
Your Google Cloud SDK is configured and ready to use!

* Commands that require authentication will use by default
* Commands will reference project `responsive-sun-123456` by default
Run `gcloud help config` to learn how to change individual settings

This gcloud configuration is called [default]. You can create additional configurations if you work with multiple accounts and/or projects.
Run `gcloud topic configurations` to learn more.

Some things to try next:

* Run `gcloud --help` to see the Cloud Platform services you can interact with. And run `gcloud help COMMAND` to get help on any gcloud command.
* Run `gcloud topic --help` to learn about advanced features of the SDK like arg files and output formatting

Install kubectl from Google

gcloud components install kubectl
RROR: (gcloud.components.install) 
You cannot perform this action because the Cloud SDK component manager 
is disabled for this installation. You can run the following command


#To list accounts whose credentials are stored on the local system:
gcloud auth list
       Credentialed Accounts
ACTIVE             ACCOUNT

#To list the properties in your active SDK configuration:
gcloud config list
account =
disable_usage_reporting = False
project = example-project

# List multiple so called 'named configurations' 
gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT                    PROJECT                DEFAULT_ZONE    DEFAULT_REGION
default  True   responsive-sun-1111    europe-west1-b  europe-west1

#To view information about your Cloud SDK installation and the active SDK configuration:
gcloud info
Google Cloud SDK [253.0.0]

Platform: [Linux, x86_64] ('Linux', 'u18gui-2', '4.15.0-54-generic', '#58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019', 'x86_64', 'x86_64')
Locale: ('en_US', 'UTF-8')
Python Version: [2.7.15+ (default, Nov 27 2018, 23:36:35)  [GCC 7.3.0]]
Python Location: [/usr/bin/python2]
Site Packages: [Disabled]

Installation Root: [/usr/lib/google-cloud-sdk]
Installed Components:
  kubectl: [2019.06.28]
  core: [2019.06.28]
  beta: [2019.06.28]
  gsutil: [4.39]
  bq: [2.0.44]
  alpha: [2019.06.28]
System PATH: [/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]
Python PATH: [/usr/bin/../lib/google-cloud-sdk/lib/third_party:/usr/lib/google-cloud-sdk/lib:/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload]
Cloud SDK on PATH: [False]
Kubectl on PATH: [False]

Installation Properties: [/usr/lib/google-cloud-sdk/properties]
User Config Directory: [/home/vagrant/.config/gcloud]
Active Configuration Name: [default]
Active Configuration Path: [/home/vagrant/.config/gcloud/configurations/config_default]

Account: []
Project: [responsive-sun-123456]

Current Properties:
    project: [responsive-sun-123456]
    account: []
    disable_usage_reporting: [True]

Logs Directory: [/home/vagrant/.config/gcloud/logs]
Last Log File: [/home/vagrant/.config/gcloud/logs/2019.07.10/]

git: [git version 2.17.1]
ssh: [OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017]