Google Cloud Shell Tutorial
Introduction to Google Cloud Shell
Google Cloud Shell is an online development and operations environment accessible through the Google Cloud Console. It provides you with a command-line interface to manage your Google Cloud resources directly from your web browser. Cloud Shell comes pre-configured with essential tools and libraries, making it a powerful tool for developers and system administrators.
Starting Google Cloud Shell
To start Google Cloud Shell, follow these steps:
- Navigate to the Google Cloud Console.
- Click on the Cloud Shell icon
in the top right corner of the console.
- A new window will open at the bottom of the console, initializing your Cloud Shell session.
Basic Commands in Cloud Shell
Once your Cloud Shell session is active, you can start using it to manage your Google Cloud resources. Below are some basic commands:
gcloud projects list: Lists all projects you have access to.
gsutil ls: Lists all Cloud Storage buckets in your project.
bq query 'SELECT * FROM dataset.table': Runs a BigQuery SQL query.
Managing Resources with Cloud Shell
Google Cloud Shell allows you to manage various resources like Compute Engine instances, Kubernetes clusters, and more. Below are some examples:
Creating a Compute Engine Instance
To create a new Compute Engine instance, use the following command:
Output:
Created [https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances/my-instance]. NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS my-instance us-central1-a n1-standard-1 10.128.0.2 34.123.45.67 RUNNING
Deploying a Kubernetes Cluster
To deploy a new Kubernetes cluster, use the following command:
Output:
Creating cluster my-cluster...done. Created [https://container.googleapis.com/v1/projects/my-project/zones/us-central1-a/clusters/my-cluster]. kubeconfig entry generated for my-cluster. NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS my-cluster us-central1-a 1.18.20-gke.1500 34.123.45.67 e2-medium 1.18.20-gke.1500 3 RUNNING
Advanced Usage
Cloud Shell is not just limited to basic commands; it also supports advanced usage:
- Setting up and using Cloud SDK to interact with Google Cloud services programmatically.
- Running interactive tutorials to learn more about Google Cloud services.
- Using code editors and version control systems like Git to manage your code.
Conclusion
Google Cloud Shell is a powerful tool that provides a fully featured development environment directly from your browser. It simplifies the process of managing Google Cloud resources and offers a range of tools to enhance your development workflow. Whether you are a developer or a system administrator, Cloud Shell can greatly improve your productivity and efficiency.