
For DevOps engineers managing infrastructure on Google Cloud Platform, mastering the command-line interface is fundamental. The gcloud CLI provides a powerful, scriptable way to interact with a vast array of GCP services, enabling automation, efficiency, and fine-grained control. Relying solely on the web console can become a bottleneck for routine tasks, scaling operations, or integrating cloud management into CI/CD pipelines.
Here are ten essential gcloud commands that form the backbone of effective GCP management for DevOps:
- gcloud auth login: This is often the first step. It authenticates your local environment to your Google Cloud account, allowing you to access and manage resources. Essential for initial setup and switching between accounts.
- gcloud config set project: Manages your default project context. With many projects under management, setting the target project prevents errors and streamlines operations by specifying which project subsequent commands apply to.
- gcloud projects list: A quick way to view all projects accessible to your authenticated account. Useful for navigating the project landscape and confirming project IDs.
- gcloud compute instances list: Provides a summary of your Compute Engine virtual machines. You can filter by zone, state, or labels, making it easy to inventory or check the status of your VMs.
- gcloud compute instances create: The command to provision new virtual machines. Allows specifying machine type, zone, image, network, and various other configurations required to launch an instance.
- gcloud compute firewall-rules create: Manages network access by defining firewall rules. Crucial for security, this command lets you control incoming and outgoing traffic based on protocols, ports, and source/destination IP ranges.
- gcloud storage buckets create: Used to create new Cloud Storage buckets. Buckets are fundamental for storing objects, logs, backups, and static website content. This command allows specifying name, location, and storage class.
- gcloud storage ls: Lists buckets and their contents. Essential for browsing storage, verifying uploads, or inspecting bucket structures from the terminal.
- gcloud iam service-accounts list: Manages Identity and Access Management service accounts. Service accounts are critical for granting permissions to applications and services, enabling secure interaction between GCP resources.
- gcloud container clusters create: For those using Kubernetes, this command provisions Google Kubernetes Engine (GKE) clusters. GKE is a managed service, and this command simplifies the creation of a Kubernetes environment.
Mastering these and other gcloud commands significantly enhances a DevOps engineer’s capability to automate tasks, manage infrastructure efficiently, and build robust cloud-based systems on Google Cloud. Integrating these commands into scripts and workflows is key to achieving scalable and repeatable operations.
Source: https://infotechys.com/google-cloud-cli-commands-for-devops/