GCP Setup¶
Detailed guide for setting up Google Cloud Platform for Cloud Agent.
Prerequisites¶
- A GCP account with billing enabled
- A GCP project
- Google Cloud SDK installed
Initial Setup¶
1. Install Google Cloud SDK¶
2. Authenticate¶
This opens a browser for OAuth authentication.
3. Create or Select Project¶
# List existing projects
gcloud projects list
# Set existing project
gcloud config set project YOUR_PROJECT_ID
# Or create new project
gcloud projects create cloud-agent-project
gcloud config set project cloud-agent-project
4. Enable Required APIs¶
5. Set Default Region/Zone¶
Service Account (Optional)¶
For advanced setups, create a service account:
# Create service account
gcloud iam service-accounts create cloud-agent \
--display-name="Cloud Agent"
# Grant Compute Admin role
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:cloud-agent@YOUR_PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/compute.admin"
VM Permissions¶
The --permissions flag grants GCP access to your VM:
Compute Engine¶
Allows: - List/create/manage Compute Engine instances - Access to instance metadata - Network operations
GKE (Kubernetes)¶
Allows: - List/access GKE clusters - kubectl operations - Container Registry access
Cloud Storage¶
Allows: - Read/write to Cloud Storage buckets - gsutil operations
Multiple Permissions¶
Firewall Rules¶
Cloud Agent automatically creates firewall rules to:
- Allow SSH (port 22) from your IP only
- Block all other inbound traffic
To whitelist additional IPs:
Cost Management¶
VM Costs¶
| Machine Type | vCPUs | RAM | ~Monthly Cost |
|---|---|---|---|
| e2-standard-2 | 2 | 8 GB | ~$50 |
| e2-standard-4 | 4 | 16 GB | ~$100 |
| e2-standard-8 | 8 | 32 GB | ~$200 |
Cost Saving Tips¶
- Stop when not using:
ca stop - Use smaller machine types for simple tasks
- Terminate when done:
ca terminate - Set up billing alerts in GCP Console
Troubleshooting¶
"Permission Denied" Errors¶
# Re-authenticate
gcloud auth login
# Verify project access
gcloud projects describe YOUR_PROJECT_ID
"API Not Enabled"¶
"Quota Exceeded"¶
Request quota increase in GCP Console or use a different region.