Skip to main content

Certification track: AI Tooling

Ollama on Google Cloud Run

Ollama on Google Cloud Run

Ollama is an open-source LLM inference server that serves large language models — Llama, Mistral, Gemma, Phi, and others — via a REST API. This module deploys Ollama on Cloud Run v2 (CPU-only, serverless) on top of the App_CloudRun foundation, which provisions and manages the shared Google Cloud infrastructure.

This guide focuses on the cloud services Ollama uses and how to explore and operate them from the Google Cloud Console and the command line. For the mechanics common to every Cloud Run application — service identity, ingress and load balancing, scaling and concurrency, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC Service Controls, backups, and the deployment lifecycle — refer to the App_CloudRun foundation guide rather than repeating them here.


What Ollama costs on RAD, and how that compares​

Ollama on RAD's Cloud Run module costs about US$85 a month, with the module fee charged once in RAD credits. Need Ollama to stay up continuously, scale across pods, or run beside other Kubernetes workloads — or see the GKE guide for that option. If you only need it occasionally — a demo, a seasonal project, something you're evaluating — a RAD-managed project can be deleted and restored within 30 days for a handful of credits (under US$1) instead of paying for it to sit idle. See Pause it for free, below. Figures are as at 8 October 2026; sources are listed at the end of this section.

What you pay on RAD​

RAD deploys Ollama, which is open source, so there is no licence fee per user. You pay for three things:

In a Google Cloud project you ownIn a project RAD manages for you
Module fee, once per deployment175 credits (US$18 at the top-up price)157.5 credits (10% lower)
Build timeAbout 3-6 credits per buildThe same
Google Cloud running costBilled by Google to your own billing account, about US$85 a month for the default configuration (table below)Metered hourly in credits; RAD publishes 38 credits a day, about 1,140 a month (about US$114 at the top-up price, US$91 at the Scale plan's rate)
Who owns whatYou own the project and its billing; RAD deploys and updates itRAD owns the project, with guardrails, quotas and budget alerts; you get console access, and a minimum purchased balance is held in reserve

10 credits cost US$1 on a one-off top-up, and less on a monthly plan. In a project RAD manages, the network and storage are shared by every application in the project, so a second application does not add a second set of them.

Default running cost in your own project (us-central1, Google list prices):

Resource (module default)Per month
Cloud Run, 4x vCPU / 8 GiB (warm)US$78.85
Cloud NAT and networkingUS$5
Cloud Storage (add-ons, backups)US$1
Totalabout US$85

How it compares​

  • No turnkey managed SaaS was verified for Ollama itself, so the honest comparison is a self-managed server: a Hetzner CPX22 (2 vCPU/4 GB) costs about $24/month, a DigitalOcean 2 vCPU/4 GB Droplet about $24/month, and a GCP Compute Engine e2-standard-2 (2 vCPU/8 GB) about $49/month.
  • This needs considerably more CPU and memory than the reference boxes below, so a self-managed equivalent would cost noticeably more than the $24-49/month entry-level class — likely a dedicated high-memory instance.
  • There is no managed SaaS that hosts your own Ollama instance the way this module does — a hosted model-inference API is a different product from a private inference server, so it isn't a like-for-like comparison and no figure is given here. The realistic alternative is self-hosting on your own hardware or a cloud VM sized for the models you run.
  • The VPS price is not the whole cost. On a bare VPS you are also the one patching the OS, rotating backups and keeping the database (if any) healthy. RAD's managed Cloud SQL, Secret Manager and monitoring cover that for you, which is the real argument for RAD over a cheaper box — not the sticker price.

Pause it for free: delete a RAD-managed project, restore it when you need it​

If Ollama runs in a project RAD manages for you, you have a second option that goes well beyond scaling to zero: delete the whole project, and restore it within 30 days for close to nothing. This suits Ollama you only need occasionally — a demo, an evaluation, a seasonal project — far better than running it continuously.

  • How it works. Deleting a RAD-managed project unlinks its billing first, then asks Google to delete the project. Google does not remove the project immediately: it keeps it, recoverable, for 30 days. Because billing is already unlinked, nothing is charged while it waits. Unlike deleting one module, this does not tear down the compute resource one by one — the whole project, and everything in it, simply stops.
  • Restoring costs a few credits, not a rebuild. Within 30 days, the project's owner can restore it. RAD asks Google to undelete the project and reattaches its billing account, then asks you to run Update on each deployment to confirm everything came back. Because nothing was individually destroyed, that Update finds the same resources already there — it is a check, not a rebuild, and an Update never charges the module fee again. That costs roughly a handful of credits (under US$1) in total for a typical 2-3-deployment chain.
  • So a month of occasional use can cost a few dollars, not US$85. Deploy Ollama, use it for a while, delete the project. Restore it next time you want it, confirm with Update, and delete it again when you're done. You pay only for the module fee once, the builds, and whatever time Ollama was actually live.
  • What this needs. You must own the project (not a bring-your-own one RAD only manages billing for), and you restore it yourself within the 30 days — after that, Google deletes it for good. Restoring is admitted like creating a new project: your purchased credit balance must still clear the tier's floor (100 credits for the sandbox tier most study and demo use fits). Google says most services are fully working again within 36 hours of a restore.
  • One real gap: nightly backups don't survive. Backups are written to a bucket inside the project, and that bucket is not protected by Cloud Storage's soft-delete, so it is very likely gone as soon as you delete the project — even though the project itself is recoverable for 30 days. If you've customised Ollama and want to keep that work, copy a backup out (to Google Drive, or a bucket outside the project) before you delete. For a default installation with nothing irreplaceable in it, this does not matter.

Pay only while you use it, the other way: delete and redeploy​

The option above only applies to a RAD-managed project; in your own project, or once the 30-day window has passed, the way to stop paying is to delete the deployment and deploy it again when you need it.

  • What a redeploy costs. The module fee again plus the builds: about 180 credits (US$18) in your own project, or 162 credits in a RAD-managed one. Deleting saves money once Ollama would otherwise sit unused for about 6 days or more in your own project (about US$2.83 a day), or about 4 days or more in a RAD-managed one (38 credits a day).
  • Most of the running cost is usually the database and any shared file/cache VM. They stop only when nothing else in the project uses them, so deleting Ollama while something else shares the project saves only this app's own compute part.
  • Keep your data first. Nightly backups go to a bucket inside the deployment and are deleted with it, so copy the latest backup out before deleting if you want to keep it.

Lab sessions and Managed Environments​

  • Lab sessions, for training. A trainer runs a session for a class. Each participant gets Ollama in their own Google Cloud project for 15 minutes to 24 hours, within an allowance the trainer sets. Either the trainer funds every place, or each participant pays for their own. Everything is deleted when the session ends and unused credits go back to the trainer.
  • Managed Environments, for consultancies. A partner runs Ollama for a client from a ring-fenced wallet it funds, and settles with the client directly. If the wallet runs low, billing pauses and the data is kept, so nobody receives an unexpected charge. At the end the partner hands the project over and the deployments become the client's own.
  • Credits can be bought in more than 20 currencies, including XAF, XOF, NGN, GHS, KES and ZAR, by card, bank transfer or mobile money.

Sources (8 October 2026): Google Cloud list prices from the Cloud Billing Catalog API; Delete and restore projects for the 30-day recovery window and what it says about Cloud Storage objects without soft delete; RAD fees and the daily-credit estimates from radmodules.dev/pricing. Prices change; check each source before relying on a figure.

1. Overview​

Ollama runs as a containerised inference server on Cloud Run v2. The deployment wires together a focused set of Google Cloud services:

CapabilityGoogle Cloud serviceNotes
ComputeCloud Run v2 (gen2)Ollama service, 4 vCPU / 8 GiB by default (3B models), request-based autoscaling
Model storageCloud Storage + GCS FuseModels bucket mounted at /mnt/gcs; weights persist across container restarts and new revisions
SecretsSecret ManagerNo app-managed secrets — Ollama requires no credentials
IngressCloud Run URL (VPC-internal)Default internal ingress; only services in the same VPC can reach the API

Sensible defaults worth knowing up front:

  • No database, no Redis. Ollama is stateless beyond its GCS-backed model cache. Neither Cloud SQL nor Redis is provisioned.
  • GCS Fuse is the persistence layer. Model weights are stored in a dedicated GCS bucket and mounted into the container at /mnt/gcs via GCS Fuse. Container restarts load models from GCS rather than re-downloading them.
  • ingress_settings = "internal" by default. Ollama is designed as a shared VPC-internal inference endpoint called by other applications (Flowise, N8N, RAGFlow, Django). Setting ingress_settings = "all" exposes the unauthenticated API to the public internet — always pair with IAP in that case.
  • execution_environment = "gen2" is required for GCS Fuse support and cannot be downgraded to gen1.
  • Automatic model pull. When default_model is set and no custom initialization_jobs are provided, a Cloud Run Job named model-pull is created on first deployment and stores the model in the GCS bucket.
  • Three environment variables are always injected: OLLAMA_MODELS, OLLAMA_HOST, and OLLAMA_KEEP_ALIVE. Do not override OLLAMA_MODELS or OLLAMA_HOST in environment_variables.

2. Google Cloud Services & How to Explore Them​

All commands assume PROJECT and REGION are set. Service and resource names are reported in the deployment Outputs.

A. Cloud Run — the Ollama service​

Ollama runs as a Cloud Run v2 service (gen2) that autoscales by request load between the minimum and maximum instance counts. Each deployment creates an immutable revision; traffic can be split across revisions for safe rollouts.

  • Console: Cloud Run → select the service for revisions, traffic, logs, and metrics.
  • CLI:
    gcloud run services list --project "$PROJECT" --region "$REGION"
    gcloud run services describe <service-name> --project "$PROJECT" --region "$REGION"
    gcloud run revisions list --service <service-name> --project "$PROJECT" --region "$REGION"
    # Send a test inference request from within the VPC:
    curl -s "$OLLAMA_API_URL/api/tags" | jq '.models[].name'

See App_CloudRun for scaling, concurrency, execution environment, and traffic splitting.

B. Cloud Storage — model weight persistence​

Ollama model weights are stored in a dedicated GCS bucket (named <resource_prefix>-models) and mounted into the container via GCS Fuse at /mnt/gcs. The environment variable OLLAMA_MODELS is set to /mnt/gcs/ollama/models so Ollama discovers and caches models there.

  • Console: Cloud Storage → Buckets → select the models bucket to browse downloaded model files.
  • CLI:
    # Bucket name is in the Outputs (models_bucket)
    gcloud storage ls gs://<models-bucket>/ollama/models/
    gcloud storage buckets describe gs://<models-bucket> --project "$PROJECT"

The bucket name is reported as the models_bucket output. See App_CloudRun for GCS Fuse, CMEK options, and lifecycle policies.

C. Secret Manager​

Ollama requires no application-managed credentials — there is no admin password and no database password. Secret Manager is available for any custom secrets you inject via secret_environment_variables.

  • Console: Security → Secret Manager.
  • CLI:
    gcloud secrets list --project "$PROJECT"
    gcloud secrets versions access latest --secret=<secret-name> --project "$PROJECT"

See App_CloudRun for injection and rotation details.

D. Networking & ingress​

The service is reachable by default only from within the same VPC (ingress_settings = "internal"). Any Cloud Run service, GKE pod, or Compute Engine VM in the VPC can call the Ollama API at the service URL on port 11434. An external HTTPS load balancer with a custom domain, Cloud CDN, and Cloud Armor can be added for external access.

  • Console: Cloud Run (service URL); Network services → Load balancing.
  • CLI:
    gcloud run services describe <service-name> \
    --region "$REGION" --format='value(status.url)'
    gcloud compute addresses list --project "$PROJECT"

See App_CloudRun.

E. Cloud Logging & Monitoring​

Container logs flow to Cloud Logging; Cloud Run metrics flow to Cloud Monitoring, with optional uptime checks and alert policies.

  • Console: Logging → Logs Explorer; Monitoring → Dashboards / Alerting.
  • CLI:
    gcloud run services logs read <service-name> \
    --project "$PROJECT" --region "$REGION" --limit 50

3. Ollama Application Behaviour​

  • No first-deploy database setup. Ollama has no database. There is no db-init job and no Cloud SQL instance.

  • Model pull on first deploy. When default_model is set and initialization_jobs is empty, a Cloud Run Job named model-pull runs once. It starts a local Ollama server in the background, pulls the named model, stores it in the GCS bucket, then shuts down. The job mounts the ollama-models GCS volume so the weights persist. The timeout is controlled by model_pull_timeout_seconds (default 3600 seconds); large models (7B+) can take 20–30 minutes on first pull.

    Inspect the job and its executions:

    gcloud run jobs list --project "$PROJECT" --region "$REGION"
    gcloud run jobs executions list --job <model-pull-job-name> \
    --project "$PROJECT" --region "$REGION"
  • Cold-start model loading. On each instance start, Ollama loads model weights from GCS Fuse. This typically takes 30–120 seconds depending on model size. The startup probe uses a 30 s initial delay with 20 failure attempts (roughly 5 minutes) to accommodate this. OLLAMA_KEEP_ALIVE is set to "24h" so loaded models stay resident between requests. Override via environment_variables.

  • Automatically injected variables. OLLAMA_MODELS (/mnt/gcs/ollama/models), OLLAMA_HOST (0.0.0.0:11434), and OLLAMA_KEEP_ALIVE (24h) are injected automatically. Do not override the first two; the third may be overridden.

  • Health endpoint. The Ollama root path (/) responds with "Ollama is running" once the server is ready. Both startup and liveness probes target this path.

  • Additional tuning. Use environment_variables to set OLLAMA_NUM_PARALLEL (default 1, increase for concurrent callers), OLLAMA_ORIGINS (restrict CORS), and other Ollama environment variables.


4. Configuration Variables​

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

Group 1 — Project & Identity​

VariableDefaultDescription
project_id(required)Target Google Cloud project.
regionus-central1Region for the service and regional resources.

Group 2 — Deployment Environment​

VariableDefaultDescription
tenant_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.

Group 3 — Application Identity​

VariableDefaultDescription
application_nameollamaBase name for resources. Do not change after first deploy.
application_display_nameOllama LLM ServerFriendly name shown in the Console.
description(set)Service description.
application_versionlatestOllama image tag; pin to a specific version (e.g., 0.3.12) in production.

Group 4 — Runtime & Scaling​

VariableDefaultDescription
deploy_applicationtrueSet false to provision storage and IAM without deploying the service.
cpu_limit4000mCPU per instance. 3B models: "4000m"; 7B models: "8000m". Cloud Run max is "8".
memory_limit8GiMemory per instance. 3B models: "8Gi"; 7B models: "16Gi".
min_instance_count1Minimum instances. Keep ≥ 1 to avoid 60–120 s cold-start model-loading latency.
max_instance_count1Maximum instances. LLM inference is CPU-saturating; multiple instances increase cost.
execution_environmentgen2Must remain "gen2" — required for GCS Fuse volume mounts.
timeout_seconds3600Maximum request duration. Large model inference can be slow; 3600 s is the Cloud Run maximum.
container_protocolhttp1HTTP protocol version.
traffic_split[]Traffic allocation across revisions for canary deployments. All entries must sum to 100.
enable_image_mirroringtrueMirror ollama/ollama to Artifact Registry to avoid Docker Hub rate limits.

Group 5 — Access & Networking​

VariableDefaultDescription
ingress_settingsinternalKeep "internal" for VPC-only access. "all" exposes the unauthenticated API to the public internet.
vpc_egress_settingPRIVATE_RANGES_ONLYOutbound traffic routing through VPC.
enable_iapfalseRequire Google sign-in via Identity-Aware Proxy. Required when ingress_settings = "all".
iap_authorized_users / iap_authorized_groups[]Who may access through IAP.
enable_cloud_armorfalseAttach a Cloud Armor WAF fronted by a Global HTTPS Load Balancer.
application_domains[]Custom domain names for the HTTPS load balancer.
enable_cdnfalseEnable Cloud CDN on the HTTPS load balancer.
enable_vpc_scfalseEnforce a VPC-SC perimeter (requires organization_id).
enable_audit_loggingfalseDetailed Cloud Audit Logs.

Group 6 — Environment Variables & Secrets​

VariableDefaultDescription
environment_variables{}Extra non-secret settings. OLLAMA_MODELS, OLLAMA_HOST, and OLLAMA_KEEP_ALIVE are injected automatically. Use OLLAMA_NUM_PARALLEL, OLLAMA_ORIGINS, etc. here.
secret_environment_variables{}Map of env var → Secret Manager secret name.

Group 7 — Backup & Maintenance​

Not applicable for Ollama — model weights are stored durably in GCS. These variables are present for interface compatibility only. See App_CloudRun.

Group 8 — CI/CD & Binary Authorization​

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

Group 9 — NFS Instance & Custom Initialization​

VariableDefaultDescription
initialization_jobs[]Leave empty and set default_model to use the auto-generated model-pull job. Provide a non-empty list to replace it entirely.
cron_jobs[]Recurring Cloud Run Jobs triggered by Cloud Scheduler.

Group 11 — Storage & Filesystem​

VariableDefaultDescription
create_cloud_storagetrueProvision GCS buckets in storage_buckets. The models bucket is always created regardless.
storage_buckets[]Additional GCS buckets beyond the models bucket.
enable_nfsfalseNot required for Ollama (uses GCS Fuse).
gcs_volumes[]Additional GCS Fuse volume mounts. The ollama-models bucket at /mnt/gcs is always appended automatically.
manage_storage_kms_iam / enable_artifact_registry_cmekfalseCMEK options.
max_images_to_retain / delete_untagged_images / image_retention_days(set)Artifact Registry cleanup policy.

Group 12 — Database Backend​

Not applicable for Ollama. database_type is fixed to "NONE" — no Cloud SQL instance is provisioned. These variables are present for interface compatibility only.

Group 14 — Observability & Health​

VariableDefaultDescription
startup_probe{ type="HTTP", path="/", initial_delay_seconds=30, failure_threshold=20 }20-attempt threshold allows ~5 minutes for model loading from GCS.
liveness_probe{ type="HTTP", path="/", initial_delay_seconds=60, failure_threshold=3 }60 s delay avoids false restarts during model load.
uptime_check_config{ enabled=false, path="/" }Cloud Monitoring uptime check.
alert_policies[]Metric alert policies.
max_revisions_to_retain7Not referenced — declared for interface compatibility only; has no effect on this module's deployment.

Group 19 — Ollama Model Configuration​

VariableDefaultDescription
default_model""Model to pull on first deployment (e.g., "llama3.2:3b", "mistral", "llama3:8b"). Leave empty to skip the auto-pull job.
model_pull_timeout_seconds3600Timeout for the model-pull Cloud Run Job. Large models (7B+) can take 20–30 minutes. Valid range: 300–7200.

5. Outputs​

Returned on a successful deployment — the quickest way to locate and explore the running resources.

OutputDescription
service_nameCloud Run service name.
ollama_api_urlOllama REST API base URL — append /api/generate, /api/chat, etc. Constructed as <api_url>/api.
service_locationRegion the service runs in.
stage_servicesStage-specific service URLs (Cloud Deploy).
models_bucketGCS bucket name where Ollama model weights are persisted.
storage_bucketsAll provisioned Cloud Storage buckets.
network_name / network_exists / regionsVPC network, presence, regions.
container_image / container_registryDeployed image and Artifact Registry repo.
monitoring_enabled / monitoring_notification_channels / uptime_check_namesMonitoring status, channels, uptime checks.
initialization_jobsNames of the setup jobs (including model-pull when triggered).
deployment_id / tenant_id / resource_prefixNaming identifiers.
project_id / project_numberProject identifiers.
cicd_enabled / github_repository_url / github_repository_owner / github_repository_name / cicd_configurationCI/CD status and details.
artifact_registry_repository / cloudbuild_trigger_name / cloudbuild_trigger_idRegistry and build trigger.
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
ingress_settingsinternalCritical"all" exposes the unauthenticated Ollama API publicly — any internet caller can query or load models.
enable_iaptrue if ingress_settings = "all"CriticalWithout IAP, the API is unauthenticated and publicly reachable. Ollama has no built-in auth.
memory_limit8Gi (3B) / 16Gi (7B)CriticalInsufficient memory causes OOM-kill mid-inference; container restarts in a loop. Allocate at least 2× the model's quantised weight size.
execution_environmentgen2 (default)HighGen1 does not support GCS Fuse mounts. Downgrading silently prevents model persistence.
cpu_limit4000m (3B) / 8000m (7B)HighToo few CPUs makes token generation extremely slow (minutes per token on 7B models).
min_instance_count1High0 enables scale-to-zero but causes 60–120 s cold starts while the model reloads from GCS.
model_pull_timeout_seconds3600HighA short timeout causes the model-pull Job to fail before the download completes for models over 2 GB.
startup_probe.failure_threshold20 (default)HighToo low a threshold causes Cloud Run to kill and restart the container before Ollama is ready after GCS Fuse mount.
timeout_seconds3600HighLLM inference for large prompts can exceed 5 minutes. Requests to long-running generations are terminated with a 504 if too short.
max_instance_count1–3HighEach instance independently loads the model. Multiple instances are safe but significantly increase cost and GCS read traffic.
default_modelset to desired modelMediumLeaving empty is safe for initial deploy but the API returns an error on all inference requests until a model is pulled manually.
environment_variables.OLLAMA_NUM_PARALLEL2–4 for shared useMediumDefault 1 serialises all requests. Increase for shared VPC endpoints with concurrent callers.
environment_variables.OLLAMA_KEEP_ALIVE24h (injected automatically)MediumOllama's own default (5m) evicts models from memory, causing 30–60 s reload delays. The module injects 24h automatically.
environment_variables.OLLAMA_ORIGINSrestrict for browser useMediumOllama's default CORS policy accepts any origin. Restrict to specific UI origins when exposed through a load balancer.
gcs_volumes mount optionsinclude implicit-dirsMediumWithout implicit-dirs, GCS Fuse directory listings fail and Ollama cannot discover cached models.
enable_image_mirroringtrueMediumDisabling pulls from Docker Hub, which is rate-limited. Keep true in production.

For the foundation behaviour referenced throughout — service identity, scaling and concurrency, ingress and load balancing, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC-SC, backups, and image mirroring — see App_CloudRun. Ollama-specific shared application configuration is described in Ollama_Common.

Need RAD to do something it does not do yet? Request it on the roadmap, or vote on what is already there.