Skip to main content

Metabase Common Module

Metabase Common is the shared application configuration module for Metabase deployments. It is called internally by Metabase CloudRun and Metabase GKE — it is not deployed directly.


Purpose

Metabase Common assembles the four values consumed by the Foundation Modules (App CloudRun and App GKE):

  • config — The application configuration object containing the container image, port, resource limits, database settings, probes, environment variables, and initialization jobs.
  • storage_buckets — Returns an empty list. Metabase does not require dedicated GCS storage — all state is stored in the PostgreSQL application database.
  • path — The filesystem path to this module, used to resolve the db-init.sh script path.

Note: Unlike Grafana Common, Metabase Common does not expose a secret_ids output — metabase.tf sets module_secret_env_vars = {} directly.


Container Configuration

Metabase Common sets the following fixed values in its config output:

FieldValueNotes
container_imagemetabase/metabaseOfficial Metabase Docker Hub image.
image_sourcecustomCloud Build compiles a custom image with the platform entrypoint script.
container_port3000Metabase's Jetty port. Must match MB_JETTY_PORT.
database_typePOSTGRES_15PostgreSQL 15 is required. Fixed — cannot be overridden.
cloudsql_volume_mount_path/cloudsqlCloud SQL Auth Proxy Unix socket mount path.
enable_mysql_pluginsfalseNot applicable for PostgreSQL.
enable_postgres_extensionsfalseNot required for Metabase.

Fixed Environment Variables

Metabase Common merges the following environment variables into the config.environment_variables output. Do not override these in the parent module:

VariableValueNotes
MB_JETTY_PORT"3000"Metabase Jetty HTTP port. Must match container_port.
JAVA_TIMEZONE"UTC"JVM timezone. UTC ensures consistent timestamp handling in dashboards.

Health Probes

Both the startup and liveness probes target /api/health. Metabase requires a generous initial delay due to JVM startup time:

ProbePathInitial DelayPeriodFailure Threshold
Startup/api/health120s10s15 (total tolerance: ~270s)
Liveness/api/health120s30s3
Readiness/api/health60s15s3

Default Initialization Job

When initialization_jobs is empty (the default), Metabase Common provides a default db-init job:

FieldValue
namedb-init
imagepostgres:15-alpine
execute_on_applytrue
script_pathMetabase_Common/scripts/db-init.sh
max_retries3
cpu_limit1000m
memory_limit512Mi

The db-init.sh script idempotently creates the Metabase PostgreSQL database and user before Metabase first boots. Override initialization_jobs with a non-empty list to replace this default entirely.


Storage Buckets

Metabase Common returns an empty storage buckets list. Metabase stores all application state in PostgreSQL. Add buckets via the storage_buckets variable in the parent CloudRun or GKE module if required (e.g., for Metabase Enterprise Edition S3-compatible storage or custom plugin artifacts).


Variables

VariableDefaultDescription
application_name'metabase'Application name used in resource naming.
deployment_id""Unique deployment ID passed from the parent module.
application_version'v0.51.3'Metabase version tag for the container build.
db_name'metabase'PostgreSQL database name.
db_user'metabase'PostgreSQL application user.
enable_cloudsql_volumetrueInjects the Cloud SQL Auth Proxy sidecar.
gcs_volumes[]GCS Fuse volume mounts.
cpu_limit'2000m'CPU limit for the container. Minimum 1 vCPU; 2 vCPU recommended.
memory_limit'4Gi'Memory limit for the container. Minimum 2 Gi for the JVM.
environment_variables{}Additional plain-text environment variables.
secret_environment_variables{}Additional Secret Manager references.
initialization_jobs[]Initialization jobs. Leave empty for the default db-init job.
description'Metabase — open-source business intelligence and analytics platform'Application description.
startup_probe(see above)Startup probe configuration.
liveness_probe(see above)Liveness probe configuration.
enable_image_mirroringfalseEnable mirroring to Artifact Registry.
min_instance_count1Minimum instances.
max_instance_count3Maximum instances.
region'us-central1'GCP region for resource deployment.

Scripts

The Metabase_Common/scripts/ directory contains:

  • db-init.sh — PostgreSQL initialization script executed by the default db-init Cloud Run Job or Kubernetes Job. Creates the Metabase database and user idempotently.
  • Dockerfile — Docker build context for the custom Metabase image built by Cloud Build.