Info Sharing Blog

Tuesday, June 25, 2019

Google Cloud : Basic Cloud Shell commands

June 25, 2019 Posted by jaacostan
Google Cloud resources can be managed in multiple ways. It can be done using Cloud Console, SDK or by using Cloud Shell.
A few basic Google Cloud shell commands are listed below.

1)    List the active account name
gcloud auth list
2)    List the project ID
gcloud config list project
3)    Create a new instance using Gcloud shell
gcloud compute instances create [INSTANCE_NAME] --machine-type n1-standard-2 --zone [ZONE_NAME]
Use gcloud compute machine-types list to view a list of machine types available in particular zone. If the additional parameters, such as a zone is not specified, Google Cloud will use the information from your default project. To view the default project information, use gcloud compute project-info describe
4)    SSH in to the machine
gcloud compute ssh [INSTANCE_NAME] --zone [YOUR_ZONE]
5)    RDP a windows server
gcloud compute instances get-serial-port-output [INSTANCE_NAME] --zone [ZONE_NAME]
6)    Command to check whether the server is ready for an RDP connection
gcloud compute instances get-serial-port-output
7)    Create a Storage bucket
gsutil mb gs://[BUCKET_NAME]
8)    Copy a file in to the bucket
gsutil cp [FILE_NAME] gs://[BUCKET_NAME]
9)    Setting up default compute zone
gcloud config set compute/zone [ZONE_NAME]
10)    Set the default region:
gcloud config set compute/region [REGION_NAME]
11)    List the compute engine instances created: 
gcloud compute instances list
12)    Create Kubernetes Cluster
gcloud container clusters create [CLUSTER-NAME]
13)    Get authentication credentials for the cluster
gcloud container clusters get-credentials [CLUSTER-NAME]
14)    Expose the Kubernetes resource to the internet
kubectl expose deployment hello-server --type="LoadBalancer"
!----- Passing in type="LoadBalancer" creates a Compute Engine load balancer for your container-----!
15)    Inspect the service running in Kubernetes
kubectl get service [SERVICE_NAME] 
16)    Stop an Compute Instance.
gcloud compute instances stop [INSTANCE-NAME]

About Serverless Computing Offering by Google Cloud, Continue reading here  

Look forward >> The skills for your tomorrow with courses as low as $10.99