Skip to main content

GCP Fundamentals

Global Infrastructure​

Google Cloud Platform operates on a global infrastructure consisting of:

Regions and Zones​

  • Regions: Geographical areas containing multiple zones (e.g., us-central1, europe-west1)
  • Zones: Individual data centers within a region (e.g., us-central1-a, us-central1-b)
  • Multi-region: Resources distributed across multiple geographic locations for high availability

Availability and Redundancy​

  • Zones are independent failure domains
  • Resources can be deployed across zones for fault tolerance
  • Multi-zone deployments provide automatic failover capabilities

Core Services Overview​

Compute Services​

ServiceUse CaseKey Features
Compute EngineVMs and custom infrastructureFull control, scalable, pay-per-second
GKE (Google Kubernetes Engine)Container orchestrationManaged Kubernetes, auto-scaling, networking
Cloud RunServerless containersEvent-driven, auto-scaling, pay-per-request
Cloud FunctionsEvent-driven codeServerless, trigger-based, minimal infrastructure
App EngineManaged application platformFully managed, auto-scaling, language support

Storage Services​

ServiceTypeUse Case
Cloud StorageObject storageFiles, backups, static content, data lakes
Persistent DiskBlock storageVMs, databases, high IOPS
FilestoreManaged NFSShared filesystems, legacy apps

GCP Network Architecture​

Networking Services​

ServiceFunction
VPC (Virtual Private Cloud)Network isolation and security
Cloud VPNSecure site-to-site connectivity
Cloud Load BalancingDistribute traffic across instances
Cloud InterconnectDedicated network connection
Cloud CDNContent delivery network

Identity and Access Management (IAM)​

IAM enables fine-grained access control through:

  • Roles: Bundles of permissions (Basic, Predefined, Custom)
  • Service Accounts: Identity for applications and services
  • Members: Users, service accounts, groups, and domains
  • Policies: Bind members to roles with conditions

Role Hierarchy​

  1. Basic Roles: Owner, Editor, Viewer (deprecated for new projects)
  2. Predefined Roles: Service-specific with granular permissions
  3. Custom Roles: Tailored permissions for organizational needs

GCP Resource Hierarchy​

Key Concepts:

  • Organization: Top-level container (optional)
  • Folders: Logical groupings for organizational structure
  • Projects: Resource containers for billing and access control
  • Resources: Compute, storage, databases, etc.

Security and Responsibility Model​

Google manages:

  • Physical security of hardware
  • Infrastructure security
  • Network infrastructure
  • Data center operations

Customers manage:

  • Identity and access control
  • Data encryption (application-level)
  • Network security policies
  • API security
  • Audit logging and monitoring

Billing and Cost Management​

Cost Structure​

  • Compute: Charged per second/minute of usage
  • Storage: Charged per GB per month
  • Network: Ingress free, egress charges vary by region
  • Data transfer: Between regions and to internet incur costs

Cost Optimization​

  • Committed Use Discounts (CUD): Reserve capacity for 1-3 years
  • Sustained Use Discounts (SUD): Automatic discounts for long-running resources
  • Preemptible VMs: Lower-cost, interruptible instances
  • Free tier: Always-free services with monthly quotas

Billing Controls​

  • Set budgets and alerts
  • Export billing data to BigQuery
  • Analyze costs by project, service, region
  • Use the Cost Management tools in Cloud Console

Cloud Marketplace​

The Cloud Marketplace provides:

  • Pre-built solutions and templates
  • Third-party applications
  • SaaS solutions
  • Open-source software
  • Professional services

Hands-on Exercises​

Exercise 1: Create a Compute Engine Instance​

# Set your project
gcloud config set project PROJECT_ID

# Create a VM instance
gcloud compute instances create my-instance \
--image-family ubuntu-2004-lts \
--image-project ubuntu-os-cloud \
--zone us-central1-a \
--machine-type e2-medium

# Connect via SSH
gcloud compute ssh my-instance --zone us-central1-a

# List instances
gcloud compute instances list

# Delete the instance
gcloud compute instances delete my-instance --zone us-central1-a

Exercise 2: Create a Cloud Storage Bucket​

# Create a bucket (must be globally unique)
gsutil mb gs://my-unique-bucket-name/

# Upload a file
gsutil cp local-file.txt gs://my-unique-bucket-name/

# Download a file
gsutil cp gs://my-unique-bucket-name/local-file.txt .

# List bucket contents
gsutil ls gs://my-unique-bucket-name/

# Delete the bucket
gsutil rm -r gs://my-unique-bucket-name/

Exercise 3: Assign IAM Roles​

# Grant a user Editor role on a project
gcloud projects add-iam-policy-binding PROJECT_ID \
--member=user:user@example.com \
--role=roles/editor

# Grant a service account Compute Instance Admin role
gcloud projects add-iam-policy-binding PROJECT_ID \
--member=serviceAccount:sa@PROJECT_ID.iam.gserviceaccount.com \
--role=roles/compute.admin

# View IAM policy
gcloud projects get-iam-policy PROJECT_ID

# Remove a role
gcloud projects remove-iam-policy-binding PROJECT_ID \
--member=user:user@example.com \
--role=roles/editor

Exercise 4: Create a Service Account​

# Create service account
gcloud iam service-accounts create my-service-account \
--display-name="My Service Account"

# Grant roles to service account
gcloud projects add-iam-policy-binding PROJECT_ID \
--member=serviceAccount:my-service-account@PROJECT_ID.iam.gserviceaccount.com \
--role=roles/compute.admin

# Create and download a key
gcloud iam service-accounts keys create key.json \
--iam-account=my-service-account@PROJECT_ID.iam.gserviceaccount.com

# Authenticate with the service account
gcloud auth activate-service-account --key-file=key.json

Exercise 5: Enable APIs​

# List available services
gcloud services list --available

# Enable an API
gcloud services enable compute.googleapis.com
gcloud services enable storage.googleapis.com
gcloud services enable container.googleapis.com

# List enabled APIs
gcloud services list --enabled

# Disable an API
gcloud services disable compute.googleapis.com

Key Takeaways​

  • GCP uses regions and zones for global resource deployment
  • The resource hierarchy (Organization > Folder > Project > Resource) enables scalable management
  • IAM provides granular access control through roles, members, and service accounts
  • Understanding the shared security responsibility model is critical
  • Billing controls and cost optimization tools help manage expenses
  • The gcloud CLI is essential for automation and infrastructure-as-code

Review Questions​

  1. What is the difference between a region and a zone in GCP?
  2. How does the IAM role hierarchy work?
  3. Name three ways to reduce costs on GCP.
  4. What are the components of a resource hierarchy in GCP?
  5. Which party is responsible for data encryption in GCP?