Run Bifrost in a multi-replica cluster with gossip-based peer discovery, distributed state sync, and high-availability configuration
Cluster mode enables multiple Bifrost replicas to share state - rate limits, budget counters, and governance data - across pods. When bifrost.cluster.enabled is false (the default), each replica operates independently and state is only shared via the database.
Cluster mode requires PostgreSQL as the storage backend. SQLite is single-node only.
bifrost.cluster.* is an enterprise capability. OSS images accept these values but do not run cluster mode at runtime.
When to Use Cluster Mode
Scenario
Recommendation
Single replica
Not needed
Multiple replicas, shared DB only
Enable cluster mode - the database is not polled for changes after startup, so config, virtual keys, routing rules, and RBAC written on one replica never reach the others without gossip/gRPC
Multiple replicas with strict per-minute rate limiting
Enable cluster mode - in-memory counters are synced via gossip
Geographic multi-region
Enable cluster mode with DNS or Consul discovery
Serverless platforms without peer-to-peer networking (e.g. Cloud Run)
Use broker mode instead of gossip - see note below
A shared PostgreSQL database alone does not keep replicas in sync. Each replica loads config into memory once at startup and never re-reads the database afterward, so changes made through the API or UI on one replica are invisible to the others until cluster mode (or a restart) propagates them. This applies to any multi-replica deployment, not just ones with strict rate limiting.
The Helm chart deploys the default mesh clustering, which needs nodes to
reach each other directly over gossip (10101) and gRPC (10102). On
platforms that do not allow peer-to-peer connectivity - such as Google Cloud
Run - use broker mode, where nodes only make an outbound connection to a
central relay. See Enterprise Clustering → Broker Mode.
Basic Cluster Setup
# cluster-values.yamlimage: tag: "v1.4.11"replicaCount: 3storage: mode: postgrespostgresql: external: enabled: true host: "your-postgres-host.example.com" port: 5432 user: bifrost database: bifrost sslMode: require existingSecret: "postgres-credentials" passwordKey: "password"bifrost: encryptionKeySecret: name: "bifrost-encryption" key: "encryption-key" cluster: enabled: true gossip: port: 10101 config: timeoutSeconds: 10 successThreshold: 3 failureThreshold: 3 grpc: port: 10102 # this is the default port if grpc is not mentioned, can be overridden# Spread replicas across nodes for true HAaffinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: app.kubernetes.io/name: bifrost topologyKey: kubernetes.io/hostname# Conservative scale-down: avoid killing pods mid-streamautoscaling: enabled: true minReplicas: 3 maxReplicas: 10 targetCPUUtilizationPercentage: 70 behavior: scaleDown: stabilizationWindowSeconds: 300 policies: - type: Pods value: 1 periodSeconds: 120# Give in-flight SSE streams time to drainterminationGracePeriodSeconds: 90lifecycle: preStop: exec: command: ["sh", "-c", "sleep 20"]
For version 1.4.x - you will need to expose 10102 TCP port and 10101 UDP port for cluster discovery.
The chart automatically creates a headless service (bifrost-headless) when cluster mode is enabled with a StatefulSet. For Deployments, create it manually:
Static peers require StatefulSet pod names to be stable. This approach doesn’t adapt to HPA-driven scaling - use Kubernetes or DNS discovery for dynamic replica counts.