Skip to content

Kubernetes

burrowDB ships a self-contained Helm chart in charts/burrowdb. burrow up kind and burrow up k8s install it for you; you can also use Helm directly.

What the chart runs

Object What
<release>-api Deployment API replicas (BURROW_ROLE=api), rolling update with maxUnavailable: 0, maxSurge: 1, a PodDisruptionBudget, optional HorizontalPodAutoscaler
<release>-worker Deployment Cron workers (BURROW_ROLE=worker)
db-bootstrap init container With the bundled PostgreSQL or postgres.admin.user: creates the app role (LOGIN CREATEDB, never a superuser) and its two databases with pgcrypto, as the admin role. Idempotent
migrate init container In every API and worker pod: burrow migrate. The advisory lock makes concurrent runs safe; a run with nothing to apply only checks
<release>-pgbouncer StatefulSet pgbouncer in transaction mode, plus a headless Service so the migrate step can send RECONNECT to each one by name, and a PodDisruptionBudget when there are two or more
<release> Service The API (ClusterIP on port 80 by default; LoadBalancer in the cloud modules)
<release>-metrics Service Headless; every burrow pod's /metrics on port 8090
<release> ServiceMonitor With metrics.serviceMonitor.enabled=true (needs the Prometheus Operator CRDs)
Ingress Optional (ingress.enabled)
Secret Database passwords, encryption key, superuser password, S3 keys that do not come from an existing Secret; generated when not given and kept across helm upgrade (see Secrets)
helm test pod Checks /readyz through the Service
ConfigMaps hooks and migrations from values, mounted at /pb_hooks and /pb_migrations
Bundled PostgreSQL and MinIO Optional, for tests and kind (postgres.bundled.enabled, s3.bundled.enabled)

API pods are ready only when /readyz passes: database reachable and every registered migration applied. On stop, an API pod keeps serving for api.preStopSleepSeconds (10 s) so the Service drops it first, then finishes in-flight requests and realtime streams for up to api.shutdownTimeout (30 s, BURROW_SHUTDOWN_TIMEOUT) within api.terminationGracePeriodSeconds (45 s). API and worker pods never create databases (BURROW_ALLOW_CREATE_DATABASE=false); only the migrate step may.

Every pod runs as a non-root user with seccompProfile: RuntimeDefault, no privilege escalation and all capabilities dropped; burrow containers have a read-only root filesystem (writable emptyDir at /data and /tmp), so the chart runs under the Pod Security restricted profile. Replicas of the API, the worker and pgbouncer spread over nodes and zones when they can (topologySpread, soft).

<release> is the release name, or <release>-burrowdb when the release name does not contain burrowdb, cut to 42 characters so derived names stay within Kubernetes limits.

On kind

burrow up kind --source .        # builds burrowdb:local and loads it into kind
burrow up kind                   # or pulls ghcr.io/test-zeus-ai/burrowdb at the CLI's version

Needs Docker, kind, Helm and kubectl. It:

  1. creates a kind cluster named burrowdb (if there is none) and uses the context kind-burrowdb;
  2. writes the chart to ~/.burrow/stacks/kind/chart;
  3. installs it as release burrowdb in namespace burrowdb with values-local.yaml: in-cluster PostgreSQL and MinIO, one pgbouncer, superuser admin@burrow.local, and api.replicas from --replicas (default 2);
  4. waits for the release (helm --wait, up to 10 minutes) and prints how to reach it:
kubectl --context kind-burrowdb -n burrowdb port-forward svc/burrowdb 8090:80 &
kubectl --context kind-burrowdb -n burrowdb get secret burrowdb -o jsonpath='{.data.superuser-password}' \
  | base64 -d | burrow login --url http://127.0.0.1:8090 --email admin@burrow.local --password-stdin

Run burrow up kind again to upgrade in place; the generated secrets are kept. Add --values extra.yaml for your own values. burrow down kind uninstalls the release; burrow down kind --delete-cluster deletes the kind cluster.

Tested on kind: install, superuser login, CRUD, file upload to the in-cluster MinIO, an upgrade to 3 API replicas and 2 pgbouncers that kept the generated secrets, and a rolling restart of the API and pgbouncer under load with 27,221 of 27,221 requests answered 200.

On an existing cluster

You need a PostgreSQL server the cluster can reach (burrowDB is tested on PostgreSQL 17), and an S3-compatible bucket. Write a values file:

# my-values.yaml
secrets:
  mode: explicit                        # nothing generated: every secret below comes from a Secret
postgres:
  host: mydb.example.internal
  user: burrow                          # ordinary role: LOGIN CREATEDB, owns its databases, not a superuser
  existingSecret: burrowdb-postgres     # key postgres-password; must be URL-safe
  sslmode: require
  admin:                                # optional: lets the chart create the role and databases
    user: dbadmin
    existingSecret: burrowdb-postgres-admin   # key postgres-admin-password
encryptionKeyExistingSecret: burrowdb-encryption   # key encryption-key (32 characters); never change it
s3:
  endpoint: ""                          # empty for AWS S3; https://storage.googleapis.com for GCS
  bucket: my-burrowdb-files
  region: eu-west-1
  existingSecret: burrowdb-s3           # keys s3-access-key, s3-secret
superuser:
  email: admin@example.com
  existingSecret: burrowdb-superuser    # key superuser-password
appURL: https://api.example.com
api:
  replicas: 3
ingress:
  enabled: true
  className: nginx
  host: api.example.com
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
  tls:
    - {hosts: [api.example.com], secretName: burrowdb-tls}

Install it:

burrow up k8s --kube-context my-cluster --values my-values.yaml

--kube-context is required: burrow never installs into the current context by default. --values is required too. --namespace (default burrowdb), --release (default burrowdb), --replicas (default 2, sets api.replicas) and --image work as for kind. burrow up k8s runs helm upgrade --install --wait --timeout 10m, so running it again upgrades.

Or with Helm directly, from a checkout:

helm --kube-context my-cluster upgrade --install burrowdb charts/burrowdb \
  -n burrowdb --create-namespace -f my-values.yaml

Remove it with burrow down k8s --kube-context my-cluster (or helm uninstall). The release Secret has helm.sh/resource-policy: keep and stays; delete it yourself if you mean to.

Secrets, helm upgrade and GitOps

With secrets.mode: generate (the default) the chart generates any secret it is not given and, on helm upgrade, reads the live Secret with lookup and keeps the values. lookup returns nothing under helm template, helm install --dry-run (client side), Argo CD and Flux: there, every render would generate new values, rotating the database password and the encryption key on each sync. The migrate step then fails against the old password, and a new encryption key makes stored settings unreadable.

For any of those flows set secrets.mode: explicit. The chart then generates nothing and fails to render unless every needed secret comes from a value or an existing Secret (postgres.existingSecret, postgres.admin.existingSecret, encryptionKeyExistingSecret, superuser.existingSecret, s3.existingSecret, smtp.existingSecret). Existing Secrets are best: keep them in your secret manager (External Secrets, Sealed Secrets, SOPS). The pods' checksum/secret annotation hashes the values given to the chart, not generated ones, so rendering twice does not roll the pods.

Exposing it

The API Service is ClusterIP by default. To expose burrowDB, use the Ingress with TLS (above). A LoadBalancer Service serves plain HTTP; if you use one, restrict it:

service:
  type: LoadBalancer
  annotations:                                  # an internal load balancer, for example
    service.beta.kubernetes.io/aws-load-balancer-scheme: internal
  loadBalancerSourceRanges: [10.0.0.0/8]        # client ranges allowed in
  externalTrafficPolicy: Local                  # keep client IPs

/metrics, /livez and /readyz answer without authentication on the same port as the API. Scrape /metrics through the headless <release>-metrics Service from inside the cluster, and block it on the public path, for example with ingress-nginx:

ingress:
  annotations:
    nginx.ingress.kubernetes.io/server-snippet: |
      location = /metrics { return 404; }

PostgreSQL for the chart

  • burrowDB should connect as an ordinary role with LOGIN and CREATEDB that owns burrow_data and burrow_aux, never as a superuser (or rds_superuser, cloudsqlsuperuser, azure_pg_admin): the dashboard's SQL console and backup restore run with that role's rights. That is all migrate, backups and restore need: restore creates a database and renames its own databases.
  • Set postgres.admin.user (and its password) to an admin login and the db-bootstrap init container creates the role and both databases (LC_COLLATE 'C' LC_CTYPE 'C' TEMPLATE template0) and installs pgcrypto in them. Or do it yourself once:
CREATE ROLE burrow LOGIN CREATEDB PASSWORD '...';
GRANT burrow TO CURRENT_USER WITH SET TRUE;   -- PostgreSQL 16+, when you are not a superuser
CREATE DATABASE burrow_data OWNER burrow ENCODING 'UTF8' LC_COLLATE 'C' LC_CTYPE 'C' TEMPLATE template0;
CREATE DATABASE burrow_aux  OWNER burrow ENCODING 'UTF8' LC_COLLATE 'C' LC_CTYPE 'C' TEMPLATE template0;
\c burrow_data
CREATE EXTENSION IF NOT EXISTS pgcrypto;
\c burrow_aux
CREATE EXTENSION IF NOT EXISTS pgcrypto;

With the databases in place you can set postgres.createDatabases: false. - A restore loads the backup into a new database as the app role, so pgcrypto must be creatable by it (it is a trusted extension; on Azure it must be allow-listed in azure.extensions, which the Azure module does). - Recommended server settings: jit=off and idle_in_transaction_session_timeout=60s. - Connection budget: pgbouncer.replicas x pgbouncer.maxDbConnections plus one LISTEN connection per replica plus the migrate step plus headroom must stay under max_connections. With the defaults (2 x 80) that means max_connections of 200 or more.

Files

With more than one API replica, set s3.*. The chart warns in its notes when api.replicas is above 1 and no S3 storage is configured. Backups go to backups.bucket, or to s3.bucket when that is empty. Scheduled backups (backups.cron) are only turned on with S3: without it they would land in a pod's emptyDir and disappear with the pod.

Hooks and migrations

Put small JS files straight in the values:

hooks:
  audit.pb.js: |
    onRecordAfterCreateSuccess((e) => {
      e.app.logger().info("created", "collection", e.record.collection().name, "id", e.record.id)
      e.next()
    })
migrations:
  1733400000_add_index.js: |
    migrate((app) => { /* up */ }, (app) => { /* down */ })

A change to them changes the pods' checksum annotation, so a helm upgrade rolls the pods and the new migrate step applies new migrations. For larger sets, build your own image FROM burrowDB with the files in /pb_hooks and /pb_migrations.