gcp-cloud-sql
БесплатноБез исполняемых скриптовНе проверенProvision and manage Cloud SQL instances on Google Cloud for MySQL, PostgreSQL, and SQL Server. Configure high availability, read replicas, automated backups…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
GCP Cloud SQL
Overview
Cloud SQL is Google Cloud's managed relational database service for MySQL, PostgreSQL, and SQL Server. It handles patches, upgrades, replication, automated backups, point-in-time recovery, and HA failover so applications focus on schema and queries instead of database administration.
Instructions
Core Concepts
- Instance — a managed VM running MySQL/Postgres/SQL Server with attached storage
- High Availability (HA) — synchronous replica in another zone with automatic failover
- Read replica — async read-only copy for scaling reads or cross-region DR
- Cloud SQL Auth Proxy — local sidecar that handles IAM auth, TLS, and connection routing
- Private IP — instance reachable only via VPC peering, never the public internet
- Point-in-time recovery (PITR) — restore to any second within the retention window using binary logs
Prerequisites
gcloud services enable sqladmin.googleapis.com servicenetworking.googleapis.com
# One-time: reserve a private range for VPC peering (for private IP instances)
gcloud compute addresses create google-managed-services-default \
--global --purpose=VPC_PEERING --prefix-length=16 \
--network=default
gcloud services vpc-peerings connect \
--service=servicenetworking.googleapis.com \
--ranges=google-managed-services-default --network=default
Creating a PostgreSQL Instance with HA
Editions matter: PostgreSQL 16 and later default to Enterprise Plus, which takes --tier=db-perf-optimized-N-4-style tiers and rejects db-custom-*. This guide pins --edition=ENTERPRISE so the db-custom-<vCPUs>-<MB> tiers work; for Enterprise Plus pass --edition=ENTERPRISE_PLUS --tier=db-perf-optimized-N-4 instead (not available in every region).
gcloud sql instances create orders-db \
--database-version=POSTGRES_17 \
--edition=ENTERPRISE \
--tier=db-custom-2-7680 \
--region=us-central1 \
--availability-type=REGIONAL \
--network=default \
--no-assign-ip \
--backup-start-time=02:00 \
--enable-point-in-time-recovery \
--retained-backups-count=14 \
--database-flags=cloudsql.iam_authentication=on,log_min_duration_statement=500
# Set the postgres password (or skip and use IAM auth exclusively)
gcloud sql users set-password postgres \
--instance=orders-db \
--password="$(openssl rand -base64 24)"
# Create application database and user
gcloud sql databases create orders --instance=orders-db
gcloud sql users create app_user --instance=orders-db --password="$(openssl rand -base64 24)"
Creating a MySQL Instance
gcloud sql instances create analytics-db \
--database-version=MYSQL_8_4 \
--edition=ENTERPRISE \
--tier=db-n1-standard-2 \
--region=us-central1 \
--storage-type=SSD \
--storage-size=100 \
--storage-auto-increase \
--backup-start-time=03:00 \
--enable-bin-log
Read Replicas
# Read replica in the same region (scale reads)
gcloud sql instances create orders-db-replica \
--master-instance-name=orders-db \
--region=us-central1 \
--tier=db-custom-2-7680
# Cross-region replica (DR + low-latency reads in another region)
gcloud sql instances create orders-db-eu \
--master-instance-name=orders-db \
--region=europe-west1 \
--tier=db-custom-2-7680
# Promote a replica to a standalone primary (DR failover)
gcloud sql instances promote-replica orders-db-eu
Connecting via Cloud SQL Auth Proxy
# Get the connection name
gcloud sql instances describe orders-db --format="value(connectionName)"
# Returns: shop-prod-4821:us-central1:orders-db
# Install the proxy v2 (current release 2.26): brew install cloud-sql-proxy, or use the
# container image gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.26.2. If you download a
# binary instead, verify its checksum against the release page before running it.
# Run the proxy locally (use --private-ip for private-IP-only instances, from inside the VPC)
cloud-sql-proxy --port 5432 shop-prod-4821:us-central1:orders-db
# In another terminal:
psql "host=127.0.0.1 port=5432 user=app_user dbname=orders"
# Cloud Run sidecar pattern (Cloud Run handles the proxy automatically with --add-cloudsql-instances)
# For GKE, deploy the proxy as a sidecar in the same pod:
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
template:
spec:
serviceAccountName: api-sa # bound to the GSA app-sa, with roles/cloudsql.client and roles/cloudsql.instanceUser
containers:
- name: api
image: gcr.io/shop-prod-4821/api:latest
env:
- name: DATABASE_URL
value: "postgresql://app-sa%[email protected]:5432/orders"
- name: cloud-sql-proxy
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.26.2
args:
- "--auto-iam-authn"
- "--private-ip"
- "shop-prod-4821:us-central1:orders-db"
securityCont
Установить gcp-cloud-sql в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл gcp-cloud-sql?
Provision and manage Cloud SQL instances on Google Cloud for MySQL, PostgreSQL, and SQL Server. Configure high availability, read replicas, automated backups, IAM database authentication, the Cloud SQL Auth Proxy, and Terraform deployments. Use for managed relational databases on GCP.
Как установить скилл gcp-cloud-sql?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл gcp-cloud-sql запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic