Codes to work with Google Cloud SDK

  • date 11th March, 2021 |
  • by Prwatech |
  • 0 Comments

Working with GCP resources using gcloud commands

 

Prerequisites

Hardware : GCP

Google Account

These codes which can be used in GCP cloud SDK to work in it. It will help to familiarize with cloud SDK codes, which can be used for multiple purposes.

 gcloud compute instances list               

List the instances which is created.

$ gcloud compute instances start <INSTANCE_NAME>      

To start instance.

gcloud compute instances stop <INSTANCE_NAME>         

To stop instance.

$          gcloud compute instances delete <INSTANCE_NAME>            

To delete the instance. Press y to confirm

gcloud compute instances create <INSTANCE_NAME> --boot-disk-size= <DISK_SIZE_IN_GB> --machine-type= <MACHINE_TYPE>  

To create instance.

Choose the zone which you want by specifying the respective number, and press enter.

$          gcloud init                                                                

For initializing the gcloud.

Choose which project you want to work with by typing the corresponding number. You can create a new project also. Choose the region and zone. Y for new region and zone. N for default.

$          gcloud components list                                        

Installed components list.

 gcloud components install <COMPONENT_ID>          

To install component.

NB: To install and remove the components we need the administrator access.

Now we can install the components. When executing it, it’ll open a command prompt showing installations. Press Y for install.

$          gcloud components remove <COMPONENT_ID>          

To remove component. A command prompt will be opened. Press Y to remove the component.

 gcloud components update                                

To update components. Execute this code and when asked, Press y. It will be updated.

$          gcloud  projects list                                                          

To show the projects. It will show the projects which we are working with.

  gcloud config set project <PROJECT_ID>                       

To set project.

$          gcloud projects create <PROJECT_ID>              

To create project.

Note: The project-id should be unique. No other project in the world should not have same project-id.

gcloud compute zones list                                                           

To List zones.

$          gcloud compute regions list                                                        

To List regions.

gcloud compute machine-types list                              

To show list of machines.

$          gcloud compute images list                                             

To list images.

gcloud auth list                                           

Lists the Authentication accounts.

Quick Support

image image