Skip to main content

Certification track: Professional Cloud Database Engineer (PCDE)

Supabase on GKE Autopilot

Supabase on GKE Autopilot

Supabase is an open-source Firebase alternative — a full backend-as-a-service built on PostgreSQL. It provides a PostgreSQL 15 database with the pgvector extension, real-time subscriptions, GoTrue authentication, PostgREST REST APIs, an S3-compatible storage service, and an admin Studio dashboard, all behind a Kong API gateway. This module deploys Supabase on GKE Autopilot on top of the App_GKE foundation, which provisions and manages the shared Google Cloud and Kubernetes infrastructure.

GKE only. Supabase is available in the GKE variant only. Its multi-service architecture (Kong gateway, GoTrue, PostgREST, Realtime, Storage, Studio) requires persistent connections and Kubernetes primitives that Cloud Run does not support.

This guide focuses on the cloud services Supabase uses and how to explore and operate them from the Google Cloud Console and the command line. For the mechanics that are common to every GKE application — Workload Identity, ingress, autoscaling, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC Service Controls, backups, and the deployment lifecycle — refer to the App_GKE foundation guide rather than repeating them here.


1. Overview

The Supabase deployment runs a Kong API gateway as the primary GKE workload, fronting a set of Supabase microservices. It wires together the following Google Cloud services:

CapabilityGoogle Cloud serviceNotes
API gateway (compute)GKE AutopilotKong gateway pods, 1 vCPU / 2 GiB by default, horizontally autoscaled
MicroservicesGKE Autopilot (additional services)GoTrue auth, PostgREST, Realtime, Storage API, Studio — each a separate Deployment
DatabaseCloud SQL for PostgreSQL 15Required — Supabase is PostgreSQL-native; pgcrypto, uuid-ossp, and pgvector extensions installed
Object storageCloud StorageA dedicated supabase-storage bucket for file uploads
SecretsSecret ManagerJWT signing secret (auto-generated), anon key, service role key, publishable key, secret key, and secret_key_base
IngressCloud Load BalancingExternal LoadBalancer, optional custom domain + managed certificate

Sensible defaults worth knowing up front:

  • PostgreSQL 15 is mandatory. The database engine is fixed; using any other engine breaks startup.
  • Kong runs in declarative (database-less) mode. Routing is defined in /home/kong/kong.yml baked into the container image — no Kong database is needed.
  • JWT credentials are auto-generated or placeholder. The JWT signing secret is auto-generated (32 random characters). The anon key and service role key are stored as placeholders and must be replaced with valid signed JWTs before production use.
  • pgvector is installed. The db-init job enables pgcrypto, uuid-ossp, and pgvector so Supabase's AI/embedding features work out of the box.
  • Image mirroring is always on. Kong and sidecar images are mirrored into Artifact Registry on every apply to avoid Docker Hub rate limits.
  • Session affinity is None. Kong is stateless; sticky routing is not required at the gateway level.

2. Google Cloud Services & How to Explore Them

All commands assume you have run gcloud container clusters get-credentials <cluster> --region <region> --project <project> and that PROJECT, REGION, and NAMESPACE are set. The namespace and other identifiers are reported in the deployment Outputs.

A. GKE Autopilot — Kong gateway and Supabase microservices

The primary GKE workload runs the Kong API gateway on port 8000. Kong routes all incoming requests to the Supabase microservices by path prefix:

Path prefixTarget servicePort
/auth/v1/*GoTrue (authentication)9999
/rest/v1/*PostgREST (REST API)3000
/realtime/v1/*Realtime (WebSocket)4000
/storage/v1/*Storage API5000

Additional Supabase services (GoTrue, PostgREST, Realtime, Storage, Studio) are deployed as separate Kubernetes Deployments in the same namespace via additional_services.

  • Console: Kubernetes Engine → Workloads → select a workload to see pods, events, and metrics. Kubernetes Engine → Services & Ingress shows the external IP.
  • CLI:
    kubectl get pods,svc,hpa -n "$NAMESPACE"
    kubectl logs -n "$NAMESPACE" deploy/<service-name> --tail=100
    kubectl describe hpa -n "$NAMESPACE" # current vs target utilisation

See App_GKE for how Autopilot, scaling, and the workload type (Deployment vs StatefulSet) are managed.

B. Cloud SQL for PostgreSQL 15

Supabase stores all application data in a managed Cloud SQL for PostgreSQL 15 instance. Pods connect through the Cloud SQL Auth Proxy sidecar over a Unix socket so no public IP is exposed. On first deploy the db-init job creates the database, user, and the required PostgreSQL extensions (pgcrypto, uuid-ossp, pgvector), then sets up the Supabase schema.

  • Console: SQL → select the instance for connections, backups, flags, and metrics.
  • CLI:
    gcloud sql instances list --project "$PROJECT"
    gcloud sql instances describe <instance-name> --project "$PROJECT"
    # Open an interactive shell:
    gcloud sql connect <instance-name> --user=<db-user> --project "$PROJECT"

The instance name, database, user, and password secret are in the Outputs. For the connection model, backups, and password rotation, see App_GKE.

C. Cloud Storage

A dedicated Cloud Storage bucket (supabase-storage) is provisioned for Supabase file uploads. The workload service account is granted access automatically. Public-access prevention is set to inherited so bucket-level ACLs can be used for serving objects.

  • Console: Cloud Storage → Buckets.
  • CLI:
    gcloud storage buckets list --project "$PROJECT"
    gcloud storage ls gs://<storage-bucket>/ # bucket name is in the Outputs

See App_GKE for CMEK options and GCS Fuse mounts.

D. Secret Manager — JWT credentials and keys

Supabase authentication is built on JWTs. Six secrets are stored in Secret Manager:

Secret suffixContentNotes
-jwt-secret32-char JWT signing secretAuto-generated if jwt_secret is empty
-anon-keyPublic anonymous JWTPlaceholder by default — must be replaced
-service-role-keyService role JWTPlaceholder by default — must be replaced
-publishable-keyPublishable (anon) opaque API keyPlaceholder if not provided
-secret-keyServer-side opaque API keyPlaceholder if not provided
-key-base64-char secret_key_base for Realtime/SupavisorAuto-generated if secret_key_base is empty

The database password is generated and managed separately by the foundation; its secret name is reported in the Outputs (database_password_secret).

  • Console: Security → Secret Manager.
  • CLI:
    gcloud secrets list --project "$PROJECT"
    # Retrieve the JWT signing secret:
    gcloud secrets versions access latest --secret=<prefix>-jwt-secret --project "$PROJECT"
    # Update the anon key after generating a signed JWT:
    echo -n "<signed-anon-jwt>" | gcloud secrets versions add <prefix>-anon-key \
    --data-file=- --project "$PROJECT"

See App_GKE for the Secret Store CSI integration and rotation.

E. Networking & ingress

By default the Kong gateway is exposed through an external Cloud Load Balancing IP. A custom domain with a Google-managed certificate can be enabled, and a static IP can be reserved so the address survives redeploys.

  • Console: Network services → Load balancing; VPC network → IP addresses.
  • CLI:
    kubectl get ingress,svc -n "$NAMESPACE"
    gcloud compute addresses list --project "$PROJECT"

See App_GKE for custom domains and static IP details.

F. Cloud Logging & Monitoring

Pod stdout/stderr flow to Cloud Logging; GKE and Cloud SQL metrics flow to Cloud Monitoring. Optional uptime checks and alert policies are available.

  • Console: Logging → Logs Explorer; Monitoring → Dashboards / Alerting.
  • CLI:
    gcloud logging read 'resource.type="k8s_container" AND resource.labels.namespace_name="'"$NAMESPACE"'"' \
    --project "$PROJECT" --limit 50

3. Supabase Application Behaviour

  • First-deploy database setup. The db-init job connects to Cloud SQL through the Auth Proxy and idempotently creates the postgres database and supabase_admin user, enables the pgcrypto, uuid-ossp, and pgvector extensions, and sets up the Supabase schema. It is safe to re-run.
  • JWT placeholder replacement. After the first deploy, the anon key and service role key secrets contain placeholder strings. These must be replaced with valid JWTs signed by the auto-generated jwt_secret before Supabase clients can authenticate:
    1. Retrieve the JWT secret: gcloud secrets versions access latest --secret=<prefix>-jwt-secret
    2. Generate an anon JWT (role: anon) and a service_role JWT (role: service_role) using jwt.io or the Supabase JWT generator.
    3. Upload each JWT: echo -n "<jwt>" | gcloud secrets versions add <secret-name> --data-file=-
    4. Restart the Kong pod to pick up the updated secrets: kubectl rollout restart deploy/<kong-workload> -n "$NAMESPACE"
  • JWT credentials are immutable as a set. The jwt_secret, anon_key, and service_role_key must always be regenerated together. Changing the JWT secret while leaving derived keys unchanged invalidates all issued tokens immediately.
  • Kong is stateless. The gateway reads routing from the declarative kong.yml baked into the image. No Kong database is used.
  • Health probes target /health. Kong's /health endpoint confirms the gateway is running and routing is configured. The startup probe allows ~3 minutes (30 s initial delay × 18 failures) for first-boot database setup to complete.
  • Realtime uses PostgreSQL LISTEN/NOTIFY. No Redis is required for the core Supabase stack; enable_redis defaults to false.

4. Configuration Variables

Variables are grouped exactly as they appear on the deployment platform. Only settings specific to or notable for Supabase are listed; every other input is inherited from App_GKE with its standard behaviour and defaults.

Group 1 — Project & Identity

VariableDefaultDescription
project_id(required)Target Google Cloud project.
regionus-central1Region for the workload and regional resources.
supabase_db_password(required)Password for the in-namespace Supabase/PostgreSQL superuser and all Supabase service roles. Must be supplied explicitly — never auto-generated.

Group 2 — Deployment Environment

VariableDefaultDescription
tenant_deployment_iddemoShort suffix that makes resource names unique per environment.
support_users[]Emails granted project access and monitoring alerts.
resource_labels{}Labels applied to all resources for cost/ownership tracking.

Group 3 — Application Identity

VariableDefaultDescription
application_namesupabaseBase name for resources. Do not change after first deploy.
application_display_nameSupabaseFriendly name shown in the Console.
application_description(set)Workload description annotation.
application_version2.8.1Kong gateway image version tag. Pin to a tested version; avoid latest in production.

Group 4 — Runtime & Scaling

VariableDefaultDescription
deploy_applicationtrueSet false to provision infrastructure only.
container_resources1000m / 2GiCPU limit and memory limit for the Kong gateway container. Raise CPU to 2000m for production traffic.
min_instance_count1Minimum Kong pod replicas. Keep ≥ 1 — cold starts disrupt OAuth redirect flows.
max_instance_count3Maximum Kong pod replicas (autoscaler ceiling).
container_port8000Kong HTTP proxy port.
enable_cloudsql_volumetrueCloud SQL Auth Proxy sidecar. Must remain true.
enable_vertical_pod_autoscalingfalseLet Autopilot tune resource requests automatically.
container_image_sourcecustomImage source mode. custom builds via Cloud Build from Supabase_Common/scripts/Dockerfile.
enable_image_mirroringtrueAlways enabled — Kong is mirrored from Docker Hub into Artifact Registry.

Group 5 — Environment Variables & Secrets

VariableDefaultDescription
environment_variables{}Extra non-secret settings. Core Kong/Supabase values are set automatically.
secret_environment_variables{}Additional Secret Manager references injected as env vars.
jwt_secret""JWT signing secret. Leave empty to auto-generate 32-char random. Treat as permanently immutable after first deploy.
anon_key""Public anonymous JWT. Leave empty; a placeholder is stored — replace post-deploy.
service_role_key""Service role JWT (full DB access). Leave empty; replace post-deploy. Never expose in client code.
publishable_key""Publishable (anon) opaque API key for newer Supabase clients. Placeholder if empty.
supabase_secret_key""Server-side opaque API key for newer Supabase clients. Placeholder if empty.
secret_key_base""64-char internal encryption secret for Realtime/Supavisor. Auto-generated if empty.
site_urlhttp://localhost:3000Base URL for GoTrue auth redirects. Set to your public domain.
api_external_urlhttp://localhost:8000External Supabase API URL for OAuth redirect construction.
supabase_public_urlhttp://localhost:8000Public base URL for the dashboard and REST API.
jwt_expiry3600JWT expiry in seconds for GoTrue-issued tokens.
pgrst_db_schemaspublic,storage,graphql_publicPostgreSQL schemas exposed by PostgREST.

Group 6 — GKE Backend & Cluster

VariableDefaultDescription
service_typeLoadBalancerHow the Kong Service is exposed externally.
session_affinityNoneKong is stateless; sticky routing not required.
workload_typenullDefaults to Deployment.
gke_cluster_name""GKE cluster name. Leave empty for auto-discovery.
namespace_name""Kubernetes namespace. Leave empty to auto-generate.
termination_grace_period_seconds60Seconds before SIGKILL after SIGTERM.
enable_network_segmentationfalseCreate Kubernetes NetworkPolicy resources.

Group 7 — StatefulSet

VariableDefaultDescription
stateful_pvc_enablednullEnable PVC templates in the StatefulSet. Leave unset — Supabase state lives in Cloud SQL and GCS, not pod-local storage.
stateful_pvc_size10GiPVC size per pod (if StatefulSet PVCs are enabled).

Group 8 — Resource Quota

VariableDefaultDescription
enable_resource_quotafalseCap namespace CPU/memory/object counts.
quota_memory_requests / quota_memory_limits""Must use binary units (4Gi, 8192Mi) — bare integers are read as bytes and block all pod scheduling.

Group 9 — Reliability Policies

VariableDefaultDescription
enable_pod_disruption_budgettrueProtect availability during node upgrades.
pdb_min_available1Raise min_instance_count above 1 if you need eviction headroom.
enable_topology_spreadfalseSpread pods across zones.

Group 10 — Observability & Health

VariableDefaultDescription
startup_probe_configHTTP /health, 30 s initial delay, 18 failuresAllows ~3 min for first-boot DB setup.
health_check_configHTTP /health, 60 s initial delay, 3 failuresLiveness probe.
uptime_check_configdisabledOptional Cloud Monitoring uptime check.
alert_policies[]Optional metric alert policies.

Group 11 — Workload Automation

VariableDefaultDescription
initialization_jobs[]Leave empty to use the built-in db-init job.
cron_jobs[]Scheduled cluster tasks (e.g. database cleanup routines).
additional_services[]Supabase microservices (GoTrue, PostgREST, Realtime, Storage API, Studio) deployed as additional Kubernetes Deployments in the same namespace. Each entry specifies name, image, port, resource limits, environment variables, and probe configuration.

Group 12 — CI/CD & GitHub Integration

Standard App_GKE Cloud Build / Cloud Deploy integration — see App_GKE. Key inputs: enable_cicd_trigger, github_repository_url, github_token, enable_cloud_deploy, enable_binary_authorization, binauthz_evaluation_mode.

Group 13 — Filesystem (NFS)

VariableDefaultDescription
enable_nfsfalseNFS is not needed for Supabase; storage is handled by GCS. Enabling it adds unnecessary cost.
nfs_mount_path/var/lib/storageMount path if NFS is enabled.

Group 14 — Cloud Storage & Artifact Registry

VariableDefaultDescription
create_cloud_storagetrueProvision the supabase-storage bucket.
storage_buckets / gcs_volumes(set by Common)Additional buckets / GCS Fuse mounts.
manage_storage_kms_iam / enable_artifact_registry_cmekfalseCMEK options.

Group 16 — Database Backend

VariableDefaultDescription
database_typePOSTGRES_15Fixed — do not change. Supabase requires PostgreSQL 15.
application_database_namepostgresDatabase name. Immutable after first deploy.
application_database_usersupabase_adminApplication user. Immutable after first deploy.
enable_postgres_extensionstrueInstall pgcrypto, uuid-ossp, and pgvector. Required.
postgres_extensions["pgcrypto","uuid-ossp","pgvector"]Extension list.
database_password_length32Generated password length (16–64).
enable_auto_password_rotationfalseZero-downtime DB password rotation.

Group 17 — Backup & Maintenance

VariableDefaultDescription
backup_schedule0 2 * * *Automated backup cron (UTC).
backup_retention_days7Retention; raise to 30–90 for production/compliance.
enable_backup_import / backup_source / backup_urirestore optionsRestore from a backup on deploy.

Group 18 — Custom SQL Scripts

enable_custom_sql_scripts, custom_sql_scripts_bucket, custom_sql_scripts_path, custom_sql_scripts_use_root — run SQL from a GCS bucket after provisioning. See App_GKE.

Group 19 — Custom Domain, Static IP & Networking

VariableDefaultDescription
enable_custom_domaintrueProvision Ingress for custom hostnames + managed certificate.
application_domains[]Hostnames to serve.
reserve_static_iptrueStable external IP across redeploys.
network_tags[]Network tags applied to GKE nodes and pods.

Group 20 — Identity-Aware Proxy (IAP)

VariableDefaultDescription
enable_iapfalseRequire Google sign-in in front of the Kong gateway.
iap_authorized_users / iap_authorized_groups[]Who may access.
iap_oauth_client_id / iap_oauth_client_secret""Required when IAP is enabled (sensitive).
iap_support_email""Shown on the OAuth consent screen.

Group 21 — Cloud Armor

VariableDefaultDescription
enable_cloud_armorfalseAttach a Cloud Armor (WAF) policy to the Ingress backend.
admin_ip_ranges[]CIDRs allowed privileged access.
cloud_armor_policy_namedefault-waf-policyPolicy name.
enable_cdnfalseEnable Cloud CDN on the GKE Ingress backend.

Group 22 — VPC Service Controls & Audit Logging

VariableDefaultDescription
enable_vpc_scfalseEnforce a VPC-SC perimeter (requires organization_id).
vpc_cidr_ranges / vpc_sc_dry_run(set)Access level CIDRs / dry-run mode.
enable_audit_loggingfalseDetailed Cloud Audit Logs.

5. Outputs

These values are returned on a successful deployment and are the quickest way to locate and explore the running resources.

OutputDescription
service_nameKubernetes Service name (Kong gateway).
namespaceNamespace the workload runs in.
service_cluster_ipIn-cluster ClusterIP.
stage_service_cluster_ipsMap of ClusterIPs for stage-specific services.
service_external_ipExternal LoadBalancer IP (when a static IP is reserved).
service_urlURL to reach the Supabase API via the Kong gateway.
database_instance_nameCloud SQL instance name.
database_nameApplication database name (postgres).
database_userApplication database user (supabase_admin).
database_password_secretSecret Manager secret holding the DB password.
database_host / database_portDB endpoint (127.0.0.1 via Auth Proxy) / port.
storage_bucketsCreated Cloud Storage buckets.
network_name / network_exists / regionsVPC network, presence, available regions.
container_image / container_registryDeployed Kong image and Artifact Registry repo.
monitoring_enabled / monitoring_notification_channelsMonitoring status and channels.
initialization_jobs / db_import_jobNames of the setup and (optional) import jobs.
deployment_id / tenant_id / resource_prefixNaming identifiers.
project_id / project_numberProject identifiers.
cicd_enabled / cicd_configurationCI/CD status and details.
github_repository_url / github_repository_owner / github_repository_nameConnected repo.
artifact_registry_repository / cloudbuild_trigger_name / cloudbuild_trigger_idBuild pipeline.
kubernetes_readyWhether the cluster/workload is ready.
vpc_sc_enabled / vpc_sc_perimeter_name / vpc_sc_dry_run_modeVPC-SC status.
audit_logging_enabled / artifact_registry_cmek_enabledAudit logging and CMEK status.

6. Configuration Pitfalls & Sensible Defaults

Risk: Critical (data loss / outage / security) — High (service degraded) — Medium (cost or partial degradation) — Low (minor).

SettingSensible valueRiskConsequence if wrong
jwt_secretauto-generated or fixed at first deployCriticalChanging it post-deploy invalidates every issued JWT; all client connections break. anon_key and service_role_key must be regenerated together.
anon_key / service_role_keysigned JWTs (replace placeholders)CriticalPlaceholder values cause every Supabase API call to return 401. All three JWT credentials must be regenerated as an atomic set.
enable_cloudsql_volumetrueCriticalMust be true. All Supabase services connect to PostgreSQL via the Auth Proxy socket; setting false causes GoTrue, PostgREST, and Storage to fail on startup.
database_typePOSTGRES_15CriticalSupabase requires PostgreSQL 15; any other engine breaks startup.
application_database_name / _userset onceCriticalImmutable after first deploy; renaming recreates the DB/user and destroys data.
enable_backup_importfalse unless restoringCriticalEnabling without a valid backup_uri fails the import job.
quota_memory_requests / _limitsbinary units (4Gi)CriticalBare integers are bytes and block all pod scheduling.
supabase_db_passwordrequiredCriticalNo default — must be supplied; no password means no DB superuser, and the Supabase schema init fails.
enable_postgres_extensionstrueCriticalpgcrypto, uuid-ossp, and pgvector are required for Supabase to function.
min_instance_count1HighSetting to 0 allows scale-to-zero; Kong cold starts take 15–30 s and disrupt OAuth redirect flows.
container_resources CPU2000m for productionHighInsufficient CPU causes elevated latency and 504 timeouts under load.
container_resources memory2Gi minimumHighToo little memory causes OOM kills under concurrent load.
startup_probe_config.failure_threshold18 (default)HighReducing below ~12 causes the pod to be killed before GoTrue and the init job finish on first deploy.
site_url / api_external_url / supabase_public_urlreal public URLsHighLocalhost defaults prevent OAuth flows and redirect construction from working outside the cluster.
application_versionpinned (not latest)MediumPulling latest risks Kong versions incompatible with the bundled declarative config.
enable_nfsfalseLowNFS is unnecessary for Supabase; enabling it adds Filestore cost and a dependency that can delay provisioning.
enable_redisfalseMediumRedis is optional. If set to true, redis_host must point to a reachable endpoint; an unreachable host causes Kong startup timeouts.

For the foundation behaviour referenced throughout — IAM and Workload Identity, autoscaling, ingress and certificates, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC-SC, backups, and image mirroring — see App_GKE. Supabase-specific application configuration shared across secrets, the Kong image build, and the database init job is described in Supabase_Common.