All Articles

[GCP] Initiate Google Cloud platform

unsplash-film

Install Google-cloud SDK

You can use snap install google-cloud-sdk --classic command to install or update Google Cloud SDK.

$ snap install google-cloud-sdk --classic

In order to login in Google SDK, run:

$ gcloud auth login 

Google allows browser to be connected with terminal to handle all the work of the SDK. Running gcloud auth login works like charm, giving full access to cloud resources

To set your project, run:

$ gcloud config set project PROJECT_ID

You can find your PROJECT_ID on Google Dashboard.

Cloud Console for browser activities

Now let’s look at creating an instance in the Cloud Console and connecting to it from the command line using the Cloud SDK.

Go to Google Compute Engine and click Compute section.

unsplash-film

Once you click CREATE to make your own VM instance, you need to set several features.

  1. Change the name
  2. Set Region for your geolocation. For me, there’s no Seoul Region now, I chose Thiland as it is the most affordable costs I can get.
  3. Choose machine-type as n1-standard-1 (about 4GB RAM Single Core Machine) for test purposes.
  4. Click Create button
unsplash-film

Once you finished your own instance, you can control all the works from Command line by using gcloud.

To check out instance lists, enter

$ gcloud compute instance list

NAME                 ZONE          MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUS
learning-cloud-demo  asia-east1-b  n1-standard-1               10.140.0.2   35.221.250.240  RUNNING

Connect Instance

You can connect instance on command line by entering

$ gcloud compute ssh learning-cloud-demo

No zone specified. Using zone [asia-east1-b] for instance: [learning-cloud-demo].
Updating project ssh metadata...⠏Updated [https://www.googleapis.com/compute/v1/projects/sincere-loader-258805].
Updating project ssh metadata...done.                                          
Waiting for SSH key to propagate.
Warning: Permanently added 'compute.858053284473595985' (ECDSA) to the list of known hosts.
Linux learning-cloud-demo 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3+deb9u1 (2019-09-20) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

jeon@learning-cloud-demo:~$

gcloud auth login permits you to access the system by internally creating a new public / private key pair and sending the public key to VM. In short, you have to wipe out worries about key pairs for connection. As long as you have access to your Google account, you can always connect to VM.


We are creating wealth every time we write a code