Running Zitadel on serverless platforms such as Cloud Run

Zitadel can run on Knative or Google Cloud Run when init and setup run as separate jobs and the database connection budget is planned. This page covers the configuration choices, trade-offs and checks before you commit.

On this page

Running Zitadel on Cloud Run: when a serverless platform fits

A platform team that wants Zitadel without operating Kubernetes nodes will ask whether Cloud Run or Knative is a sound host. Zitadel's production checklist suggests a serverless platform such as Knative or a hyperscaler equivalent like Cloud Run, and its deployment architecture documentation notes that Cloud Run can scale Zitadel from 0 to 1000 pods. The platform takes over node provisioning, operating system patching, the scheduler, load balancing across instances and horizontal scaling. Those are the parts most teams find expensive to run well. The fit is good when the team already runs other services on the same platform and accepts its networking and identity model.

The platform does not take over Zitadel's own obligations. Your team still owns the PostgreSQL database, its sizing, backups and point-in-time recovery, the masterkey and its storage, the public domain and TLS configuration, and the upgrade sequence. Zitadel must be started with the correct external domain settings, and the team must confirm how Cloud Run terminates TLS and whether the HTTP/2 and h2c behavior that Zitadel's gRPC traffic depends on is supported for the service configuration you choose. Confirm these points against the current Cloud Run and Zitadel documentation for your versions before committing.

Scaling from zero is the feature that most changes the design. Each new container instance opens its own database connections, so the number of instances, multiplied by the pool size per instance, sets the load on PostgreSQL. A scale-out event can exhaust connection limits that looked comfortable at steady state. Set a maximum instance count that the database can serve, and test a burst before go-live. Cold starts add latency to the first request after an idle period, which matters most for login flows that users wait on. Ask the platform team to measure cold start time in your region with your image, and decide whether a minimum instance count is worth its recurring cost.

How to set up Zitadel on Cloud Run with separate init and setup jobs

This sequence moves a self-hosted Zitadel from an empty PostgreSQL database to a running Cloud Run service by separating the one-off schema and setup work from the long-running start container. Each phase ends with a check, so a failure is caught before the next phase begins.

  1. Provision PostgreSQL within the supported versions

    Your platform or database team creates a PostgreSQL instance running a version from 14 through 18, which is the range Zitadel supports for self-hosting. Create a dedicated database and a login role for Zitadel, and confirm the instance is reachable from the Cloud Run network path you plan to use, including any private connectivity or connector configuration. Done means you can connect with the role from a trusted workstation or a temporary job and see the empty database. Confirm the exact role privileges and connection parameters against the current Zitadel self-hosting documentation for the version you choose, since v4.19.5 was the release cited for this sequence.

  2. Generate and store the masterkey before any job runs

    Generate the 32-byte masterkey that encrypts Zitadel secrets at rest and store it in Google Secret Manager or your chosen secrets manager. Grant only the init, setup and start service accounts access to read it, and mount it as a secret or pass it through a secure reference, never as a plain environment variable in a shared template. Done means the secret exists, the access policy is recorded, and the same value is available to every job. Losing or changing this key after data exists makes existing encrypted data unreadable, so record where it is kept before you go further.

  3. Run the init job as a one-off task

    Create a Cloud Run job that runs the Zitadel init command against your database, using the database connection settings and the masterkey secret. Run it once and let it complete. The init phase prepares the database schema and required base objects, so it must not run inside the serving container. Done means the job execution reports success in the Cloud Run job logs, and a query against the database shows Zitadel tables exist. If the job fails, correct the connection or permission problem and rerun it rather than starting the service.

  4. Run the setup job with your external domain settings

    Create a second Cloud Run job that runs the Zitadel setup command. Set the external domain, external port and external secure values to match the public hostname and HTTPS endpoint users will reach, and provide the first instance administrator configuration you need. Run it once after init has succeeded. Done means the job completes, the logs show the first instance is configured, and you have recorded the domain values because changing them later requires rerunning setup. Confirm the exact setup flags and required settings against the current self-hosting documentation for your version.

  5. Deploy the start container with masterkey and domain settings

    Deploy the Zitadel start command as the Cloud Run service. The service should only start the application, so it does not carry init or setup logic. Set the same database connection, masterkey reference and external domain values used in the jobs, and configure the port Cloud Run exposes. Give the service a minimum instance count that matches your availability needs, since scaling to zero delays the first request after an idle period. Done means the revision reaches a ready state without restart loops in the logs.

  6. Verify health endpoints and the first login

    Call the health and readiness endpoints that Zitadel exposes for the version you run, through the public domain, and confirm each returns a success response. Then open the login page in a browser, sign in as the setup administrator, and confirm the console loads over HTTPS with the expected hostname. Done means health checks pass consistently across several requests and the administrator can sign in. If the console redirects to the wrong host or returns an instance not found error, check the external domain values from the setup phase before changing anything else.

  7. Confirm the sequence is repeatable for upgrades and new revisions

    Record the job definitions, the masterkey reference, the database role and the domain values in your infrastructure code so the sequence can be reproduced. Confirm with the current Zitadel upgrade notes which init and setup steps must be rerun for a newer release, because the service revision and the jobs are separate deployments. Done means a second environment built from the same definitions reaches the same verified state. Ask your DeployOpen or internal team to review the upgrade notes for the exact version before any production change.

Which hosting option fits which team

This table compares Cloud Run, Knative on your own cluster, and a standard Kubernetes Helm deployment across operational burden, scaling, networking control and high availability. Rows marked as documented come from Zitadel's guidance, while rows marked for confirmation depend on your own platform and must be checked before you commit.

CriterionCloud RunKnative on your clusterKubernetes with Helm
Operational burdenGoogle operates the serverless runtime; your team manages images, services and the database connectionYour team runs the Kubernetes cluster and the Knative serving layer, including upgradesYour team runs the cluster, ingress, cert-manager and the Helm release lifecycle
Scaling behaviorDocumented: Zitadel's deployment architecture notes Cloud Run can scale from 0 to 1000 podsScale to zero is available through Knative serving; confirm the configured scale bounds in your environmentScaling is driven by replica counts and autoscalers you configure; scale to zero is not the default pattern
Init and setup jobsRun as separate Cloud Run jobs so that service containers only run start; confirm job ordering in your pipelineRun as separate Kubernetes jobs or hooks outside the serving revision; confirm the sequencing you needHelm hooks or separate jobs handle init and setup; confirm the chart version you deploy
Control over networkingLimited to the options Cloud Run exposes; confirm HTTP/2 support for the gRPC paths your clients needHigh control through your ingress and mesh; confirm h2c handling for gRPC upstreamsHighest control through ingress or Gateway API routing; confirm h2c and TLS termination design
Fit for high availabilityDepends on region and database design; confirm the regional behavior and failover plan you requireDepends on cluster design and your database; confirm multi-zone placement and failover testingDocumented: Zitadel recommends Kubernetes with the official Helm chart for high availability
Cold start effectsScale-from-zero adds start latency on first requests; measure it against your login flowsCold starts depend on your Knative configuration; measure them in your clusterUsually no cold start when minimum replicas run; confirm your replica floor
Database connection limitsEach new instance opens connections; plan pool sizes and a connection proxy with your database teamSame risk as Cloud Run; cap concurrency and pool size per revisionReplica count times pool size sets the total; confirm limits with your database operators

How init, setup and start containers fit around PostgreSQL

The flow starts with a one-off init job that prepares the database schema, then a setup job that configures the instance, and only then do the serving containers start. Those serving containers run the start phase alone, connect to PostgreSQL over a private path, and receive HTTPS traffic only through the platform's load balancer. The masterkey is read from a secrets store at runtime, never baked into an image. Check that the jobs finish successfully before traffic is shifted, and that the database is reachable only from the serving containers.

Init and setup jobs finish before serving containers start and reach the database.

Scaling from zero and what cold starts do to logins

Scale-to-zero is the setting that most changes how Zitadel behaves on Cloud Run or Knative, because it trades idle cost for startup latency on the first request after a quiet period. For a workforce or customer login, that first request is often the interactive sign-in page or a token endpoint call from an application, so a user may wait for a new container to start, connect to PostgreSQL and load its configuration before the flow completes. Background jobs and machine-to-machine calls usually tolerate this. Browser logins and token refreshes during a busy morning are where the delay becomes visible.

Minimum instance settings control this trade-off directly. Setting a minimum above zero keeps warm containers available so the first login does not wait for a cold start, but you pay for those instances even when no one signs in. A low minimum for the login path and a separate policy for less sensitive endpoints is a common shape to evaluate, but the right number depends on your traffic pattern and your tolerance for delay. Ask the platform team which concurrency and CPU allocation settings apply to Zitadel's API and Login containers, since each container scales on its own and the two can cold start at different times.

Measure startup time in your own environment rather than relying on a figure from a vendor page or a blog post. Deploy a staging copy with the same image version, database network path and resource limits, scale it to zero, then time the first sign-in and the first token request from a browser and an application client. Repeat the test after a realistic idle period and during a traffic burst. Record time to first byte, time to a completed login and any errors from the database connection. Those measurements, not a generic estimate, should decide the minimum instance count, and they should be repeated after each Zitadel version upgrade.

Security considerations for serverless Zitadel

Serverless Zitadel moves secrets, database credentials and job execution onto the platform, so the platform's controls become part of Zitadel's security boundary. The cards below cover the decisions that carry the most risk: how the masterkey is delivered, which identities can reach the database, how the connection is protected, who can start the init and setup jobs, how revisions are audited, and what the public endpoint exposes.

Masterkey through the secret manager

The masterkey encrypts Zitadel secrets at rest, so its delivery path matters as much as its storage. Mount it from the platform secret manager as a secret volume or versioned secret reference, and do not place it in plain environment variables, where it can appear in revision metadata, console views and logs. Confirm that only the init, setup and runtime service identities can read that secret version, and record who holds rights to create new versions. Because the masterkey cannot be rotated in place, plan its custody before the first deployment.

Production checklist

Least-privilege database service accounts

Give the init, setup and runtime services separate database roles, and keep the runtime role free of schema-changing rights. Initialization and setup need rights to create or alter schema objects, while the running service needs only the data access it uses. Pre-provision these roles on the managed database so that no service account holds superuser or database owner privileges. Review grants whenever the Zitadel version changes, because the migration steps may require different rights.

TLS from the platform to PostgreSQL

Connections from Cloud Run or Knative to PostgreSQL cross a network path you should not leave unencrypted. Set the database SSL mode to require or verify-full, and for verify-full supply the CA certificate through the secret manager so the service can validate the server name. Confirm that the platform's connector or private networking path enforces encryption and that the database rejects plaintext connections. Use the same settings in the init, setup and runtime services so none falls back to a weaker mode.

Database docs

Restricting who can invoke the jobs

Init and setup jobs change schema and configuration, so they should not be callable by anonymous users or broad project roles. Grant the invoker role only to the deployment pipeline's service identity and to named operators for break-glass use. Remove public invocation rights from job resources, and confirm that scheduled or event-triggered executions run under a dedicated identity. Keep the runtime service's permissions separate, so a compromised web container cannot start a setup run.

Audit logging of revisions

Every new revision, environment change and secret version reference is a change to the production identity system, so each should leave a record. Enable audit logs for the platform's deployment and secret access events, and forward them to a store that the workload team cannot edit. Check that you can answer who deployed which revision, which secret version it referenced and when the setup job last ran. Retain these records for the period your compliance team requires, and test a sample query before go-live.

Admin console on the public endpoint

A serverless service usually exposes one public URL, and the Zitadel console and admin APIs are served from the same host as the login pages. Decide whether administrative paths should be reachable from the internet at all, or only through an identity-aware proxy, VPN or private ingress. Restrict administrator access with strong authentication and separate administrator accounts, and verify that unauthenticated requests to admin routes are denied. Document this decision, since it determines the exposure of the whole deployment.

Self-hosting overview

Questions teams ask before running Zitadel on Cloud Run

Can Zitadel run on Cloud Run at all?

Yes, with conditions. Zitadel's production checklist suggests a serverless platform such as Knative or a hyperscaler equivalent like Cloud Run, and its deployment architecture notes that Cloud Run can scale Zitadel from 0 to 1000 pods. The setup still needs an external PostgreSQL database, a masterkey held in a secrets store, a correct external domain, and a plan for running init and setup as jobs separate from the serving containers. Confirm the current architecture guidance in the Zitadel deployment architecture docs before you commit to a design.

How much effort does it take to build and test this setup?

The effort depends on how many moving parts you own: the service and login containers, separate init and setup jobs, the external PostgreSQL role and database, TLS, the custom domain, secrets, and the scaling settings. Testing should cover a fresh install, an upgrade path, a restart during setup, and login flows under a cold start. DeployOpen does not publish a price list or estimate effort in advance; a written scope sets the effort and the quote follows from it.

What does the work need from our team?

Plan to provide access and decisions before build work starts. Typical inputs are a cloud project with permission to create Cloud Run services, jobs and secrets; a PostgreSQL instance on a supported version with a role and database you can provision; DNS control for the public domain and any extra domains; and a secrets store for the masterkey. Your team should also name an owner for upgrades, backups and access reviews. Ask the vendor or your cloud provider to confirm how the Cloud Run service handles HTTP/2 and gRPC for your login flows.

Can our in-house team run this without a partner?

Often yes, if your team already operates PostgreSQL, Cloud Run and Zitadel's configuration model. The hard parts are ordering the init, setup and start phases correctly, keeping the masterkey stable, handling the external domain settings, and testing scale-to-zero behavior against your login traffic. A partner is useful when those skills are missing, when you need a fixed-scope build with written deliverables, or when you want the setup reviewed before go-live. Weigh each option against the skills and staff time you have.

What drives cost up or down on this setup?

Costs fall into two groups. Recurring cloud costs include minimum instance settings, the database instance size and storage, network egress and logging volume, and the traffic your login flows generate. One-time costs include the design, build, testing and handover work. Keeping minimum instances at zero lowers idle spend but adds cold start delay, while a higher minimum keeps logins responsive at a higher standing cost. Ask any quote to show these items separately, along with what the cloud provider bills directly and what the partner bills for.

How long does a pilot take to validate this design?

The length of a pilot is set during scoping and depends on the number of environments, the traffic profile you need to simulate, and the identity providers you connect. A useful pilot tests a clean install, a rolling upgrade, database connection behavior under load, and login latency after the service has scaled to zero. No duration is given here because none is supplied; ask for a written pilot plan with entry criteria and exit criteria before you agree a timeline.

When is Kubernetes a better choice than Cloud Run?

Kubernetes is usually the better choice when you need high availability controlled by your own cluster policies, fine-grained control over ingress, HTTP/2 routing and certificates, or a platform team that already runs clusters. Zitadel documents a Kubernetes cluster with the official Helm chart as its recommended route to high availability. Cloud Run fits teams that want managed scaling and fewer servers to patch, but it adds constraints on connection counts and cold starts. Compare both options against your operating model and read the Zitadel self-hosting overview before deciding.

Limits to confirm in your environment

Serverless platforms impose limits that a Zitadel deployment has to fit around. The cards below cover the platform and database settings to verify before you commit to a design, since each one changes how the init, setup and start phases behave under load.

Maximum pod count per project and region

Zitadel's deployment architecture notes that Cloud Run can scale Zitadel from 0 to 1000 pods. Your project and region may carry a lower instance ceiling or quota, and that ceiling caps how far the service scales before requests queue or fail. Ask your Google Cloud account team or check the quota page for the target region, then compare the number against the connection count your PostgreSQL server can handle at that scale.

Deployment architecture docs

PostgreSQL version for your release

Self-hosted Zitadel supports PostgreSQL versions 14 through 18. Confirm the version your target Zitadel release supports before you pick a managed PostgreSQL tier, because managed services may default to a version outside that range or retire one during your deployment's life. Also confirm that the database service accepts the TLS mode you plan to use from the container.

Supported PostgreSQL versions
14 to 18
Database docs

Request timeouts and HTTP/2 for gRPC

Zitadel's APIs use gRPC alongside HTTP, so the serverless ingress must pass HTTP/2 through to the container and must not cut long requests short. Check the maximum request timeout on the service, whether the front end accepts HTTP/2 end to end, and whether the container can run with h2c for upstream traffic. Test a long-running API call and a console login before you route real users to the service.

Job model against your upgrade process

Separate init and setup jobs only work if they run in the order your upgrade needs. Confirm that your pipeline can run the init and setup jobs to completion before the start service receives the new revision, and that a failed job blocks traffic rather than leaving a half-migrated schema. Decide who approves the job run and how you roll back if the setup job fails partway through.

Cache behavior under scale-out

Zitadel's beta object caches are designed around a shared Redis or Valkey service or per-server memory, and an in-memory cache is not shared across instances. When a serverless platform adds and removes pods, each new instance starts with an empty in-memory cache, which can raise database load during scale-out. Confirm which cache option you plan to use, whether a shared cache is reachable from the platform's network, and how cache misses affect latency at peak.

Secrets and masterkey delivery

The masterkey encrypts Zitadel secrets at rest and must be the same value for every container that reads the database. Confirm that your serverless platform can mount it from a managed secret store into each revision, and that a revision rollout never starts a container with a missing or different key. Because the masterkey cannot be rotated in place, check how the platform injects it before any scale event occurs.

How DeployOpen scopes and delivers a serverless Zitadel deployment

DeployOpen plans, builds, documents and supports self-hosted Zitadel inside your own cloud accounts or data centers. For a serverless Zitadel deployment, we start by agreeing on how the init, setup and start phases will run, then build and test that split before anything reaches production.

How we scope

  • Written scope that names the Cloud Run or Knative target, the Zitadel version and the PostgreSQL service it connects to
  • Mapping of init and setup jobs, the start service, and who runs each step during upgrades
  • Agreed definition of the expected traffic pattern, cold start tolerance and database connection limits for your environment
  • Fixed-scope agreement with deliverables and timeline confirmed in writing before any build work starts

How we build

  • Separate jobs for schema initialization and setup, with the runtime container limited to the start command
  • Configuration of the masterkey, external domain settings and TLS termination in your secrets and network setup
  • Connection pool sizing checked against your database limits, with scale-out settings tested under load
  • Verification of login, token issuance and admin console access across a scale-from-zero and cold start test

How we hand over

  • Runbook covering deploy order, job reruns after configuration changes and how upgrades are sequenced
  • Documented scaling limits, cold start behavior and the monitoring signals your team should watch
  • Architecture and configuration records that your security and compliance reviewers can read directly
  • Handover session with your platform engineers, covering what DeployOpen built and what your team owns

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover
  • Retesting of scaling and connection settings when Zitadel versions or your Cloud Run configuration change
  • Support scope agreed in writing, including who responds to incidents and how database changes are coordinated
  • Quotes follow from the written scope, so ask for each component (build, testing, documentation, retainer) to be priced separately

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.