Cloud Shell in GCP

What is Cloud Shell in GCP? | How to Open Cloud Shell in GCP

  • Post comments:0 Comments
  • Reading time:6 mins read

What is Cloud Shell in GCP?

Google Cloud Shell is the shell that you can use out of Google console and Cloud Shell in GCP is a Command Line Interface (CLI).

Google cloud shell is an online command-line shell window that automatically connects to your Google cloud platform account making interacting with your projects easy.

Cloud shell is one of the best features of GCP and it’s very easy to is basically a Linux environment you can access straight from the browser with all the tools you possibly might need.
Maybe not all the tools but there are plenty of them available and configured for you at the start when you activate the environment for the first time.

It might take some time before you are connected but once you are in the first thing you can notice is what project you are working on by the unique project ID.

In more complex environments you might have a couple of different projects so it’s important to understand which one you are working on and there is an easy way you can change it.

Anyways how can you work with the cloud shell you don’t have to choose I’m working either with the common line of the graphical console you can work with both tools at the same time and use which one is more suited for the task you are doing.

How to Open Google Cloud Shell in GCP:

  • Click the Activate Google Cloud Shell button at the top right of the Console Window.
  • A Cloud Shell session opens inside a new frame at the bottom of the console and displays a command-line prompt.
  • Once your Cloud Shell session is ready to use, you can do things like go to your home directory and use VI to view your bashrc configuration.
  • You have all those utilities which are required to interact with the Google-like google Cloud command, big query, and these are for cloud storage bucket. So you have everything installed in your console.

5 Tips of Cloud Shell in GCP:

  1. A keyboard shortcut to open your cloud shell environment type G & S (G followed by S)  which will open up your virtual environment.

2. When you’re typing any g-cloud command in cloud shell you can use a tab that autocompletes your command so “Com” it should do to compute instance it gets auto-completed. Press TAB twice for the Command list.

3. If you want to use project ID in any of the G cloud commands instead of hard-coding your project ID you can use this environmental variable “ echo $DEVSHELL_PROJECT_ID “ it will show your current project ID.

4. When you type your command in Cloud Shell it will be almost like half the screen if you see the prompt is almost half it is already occupied and if your command is very big it will almost come to your next line.

And if you don’t want to have this option you can use this action option called “ export PS1= ‘S’ “ which will change your prompt to this way so that you can type in the enter command it will not come to the second line.

5. cloud shell environment is an ephemeral virtual machine and it is totally free of cost but there is a weekly usage limit. Which Google puts on that and if you want to know what is your current usage limit “click on the drop-down from cloud shell and click on usage quota” so that it will give you what is your current.

App Engine Application Deployment using Cloud Shell:

  • First, clone the sample app, and run it locally in the Cloud Shell session using the App Engine development server.
  • Click the Web Preview button, and then select the port number from the displayed menu.
  • Cloud Shell opens the preview URL at its proxy service in a new browser window. When you are done previewing the App Engine app, type Control-C to stop the development server.
  • type Control-C to stop the development server.
  • we can deploy our App Engine app using the gcloud app deploy.
  • This may take a few minutes to complete.
  • Once deployed, you can open your application in the web browser.
  • The URL is at your project
  • Now, if the application has not yet finished deploying, you’ll see an error message in the web browser.
  • Simply wait until deployment is finished, and refresh the page.
  • You’ve successfully previewed and deployed an App Engine app using just your browser thanks to the power of Cloud Shell.

List of Basic Google Cloud Shell Commands:

  1. List the project ID    
 gcloud config list project

2. List the active account name      

gcloud auth list

3. Create a new instance using Gcloud shell     

 gcloud compute instances create [INSTANCE_NAME] --machine-type n1-standard-2 --zone [ZONE_NAME]

4.RDP a windows server     

 gcloud compute instances get-serial-port-output [INSTANCE_NAME] --zone [ZONE_NAME]

5.SSH into the machine        

gcloud compute ssh [INSTANCE_NAME] --zone [YOUR_ZONE]

6.Create a Storage bucket    

    gsutil mb gs://[BUCKET_NAME]

7.Command to check whether the server is ready for an RDP connection     

   gcloud compute instances get-serial-port-output

8.Copy a file into the bucket     

   gsutil cp [FILE_NAME] gs://[BUCKET_NAME]

9.Set the default region:     

   gcloud config set compute/region [REGION_NAME]

10.Setting up default compute zone     

   gcloud config set compute/zone [ZONE_NAME]

11.List the compute engine instances created:      

   gcloud compute instances list

12.Get authentication credentials for the cluster    

    gcloud container clusters get-credentials [CLUSTER-NAME]

13.Create Kubernetes Cluster  

     gcloud container clusters create [CLUSTER-NAME]

Expose the Kubernetes resource to the internet     

   kubectl expose deployment hello-server --type="LoadBalancer"

Also Read

Elastic Google Cloud Infrastructure: Scaling and Automation

Google Cloud Professional Data Engineer: Get Certified 2021 | Exam Dumps

Leave a Reply