Skip to content

Install on Kubernetes

Follow these steps to run Typefold on a Kubernetes cluster with Helm. Every Typefold pod is stateless, so replicas can run on any node: the data lives in PostgreSQL, Redis and object storage that you provide. For a single server, Docker Compose is simpler.

  • Kubernetes 1.27 or newer, with amd64 nodes. The images are built for linux/amd64 only.
  • Helm 3.8 or newer and kubectl.
  • An ingress controller (or a load balancer) that terminates HTTPS for your address and passes WebSocket connections on.
  • PostgreSQL 16 or newer, with an empty database and a user that owns it.
  • Redis 7 or newer, with maxmemory-policy noeviction. It holds the renders waiting to run, so give it persistence (AOF) if a restart should not delay them.
  • Object storage: an S3 bucket (Amazon S3 or a compatible service) or an Azure Blob Storage container. Every API and worker pod reads the same files.
  • A license key. See get a key.
  • Resources. By default the chart runs two of each component and requests about 3 CPUs and 4 GiB of memory in all. Each extra worker requests 1 CPU and 1 GiB.

The chart and the images are in Typefold’s registry, which you sign in to with your license key. Paste the key when asked for the password:

Terminal window
helm registry login registry.typefold.dev -u license

Create the database, the Redis instance and the bucket. In the bucket’s CORS rules, allow GET and PUT requests from your address (GET only for Azure); see bucket CORS and Studio.

Generate the two secrets and the sandbox token:

Terminal window
openssl rand -hex 32 # for better-auth-secret
openssl rand -base64 32 # for data-encryption-key
openssl rand -hex 32 # for sandbox-token

Then create one Secret with your connection details, in the namespace you install into:

Terminal window
kubectl create namespace typefold
kubectl --namespace typefold create secret generic typefold \
--from-literal=database-url='postgresql://typefold:<password>@<host>:5432/typefold' \
--from-literal=redis-url='redis://:<password>@<host>:6379' \
--from-literal=better-auth-secret='<first value>' \
--from-literal=data-encryption-key='<second value>' \
--from-literal=sandbox-token='<third value>' \
--from-literal=license-key='<your license key>' \
--from-literal=object-storage-access-key-id='<access key id>' \
--from-literal=object-storage-secret-access-key='<secret access key>'

The pods also pull the images with your license key:

Terminal window
kubectl --namespace typefold create secret docker-registry typefold-registry \
--docker-server=registry.typefold.dev --docker-username=license \
--docker-password='<your license key>'
Key Required Holds
database-url Yes The PostgreSQL connection URL. Add ?sslmode=require if your server needs TLS.
redis-url Yes The Redis URL; rediss:// for TLS.
better-auth-secret Yes Signs sign-in sessions and file links. At least 32 characters.
data-encryption-key Yes Encrypts secrets stored in the database. Exactly 32 random bytes in base64.
sandbox-token Yes Lets the API and the workers run template scripts in the sandbox.
license-key Yes Your license key.
object-storage-access-key-id With S3 The access key, which can read, write, list and delete objects in the bucket.
object-storage-secret-access-key With S3 Its secret.
azure-storage-connection-string With Azure The storage account’s connection string, including the account key.
data-encryption-key-previous No The previous key while you rotate it.
resend-api-key No Email sign-in through Resend.
entra-client-secret No Sign in with Microsoft.
anthropic-api-key No Lets Studio create templates from PDFs; see AI features.
deploy-api-key No The deploy key of set up from configuration.

Create values.yaml with your address, the secrets’ names and your storage:

publicUrl: https://pdf.example.com
existingSecret: typefold
imagePullSecrets: [typefold-registry]
storage:
driver: s3
s3:
endpoint: https://s3.eu-central-1.amazonaws.com
region: eu-central-1
bucket: my-typefold-bucket
forcePathStyle: false # true for most S3-compatible services
ingress:
enabled: true
className: nginx
tlsSecretName: typefold-tls
annotations:
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-body-size: 64m

For Azure, set driver: azure and azure.container instead of the s3 block. To see every value with its default:

Terminal window
helm show values oci://registry.typefold.dev/typefold-helm
Terminal window
helm install typefold oci://registry.typefold.dev/typefold-helm \
--namespace typefold --values values.yaml --wait --timeout 10m
kubectl --namespace typefold get pods
curl https://pdf.example.com/health

Helm first runs the database migrations as a Job, then starts the rest. curl prints { "status": "ok" } once the API is ready.

Without --version, Helm installs the newest release. To pin one, add its version without the v, such as --version 1.4.0.

6. Become the first platform administrator

Section titled “6. Become the first platform administrator”
  1. Create a password account for yourself. The command prints a generated password.

    Terminal window
    kubectl --namespace typefold exec deploy/typefold-api -c api -- \
    node dist/password-account.js [email protected]
  2. Read the setup token. Every API pod prints the same one:

    Terminal window
    kubectl --namespace typefold logs deploy/typefold-api -c api | grep setupToken
  3. Open your address, sign in, and finish setup as in install.

Deployment What it does Replicas
proxy Caddy, behind your ingress. Routes Studio and the API on one address and adds the security headers. 2
api The API, sign-in and file downloads. It also sends webhooks. 2
worker Renders documents, one at a time per worker. 2
sandbox Runs template scripts and helpers. It holds no secrets, and a network policy denies it any egress. 2
studio The web app. 2

The migrations Job runs before every install and upgrade. The pods need no volumes and no service account token, run as a non-root user on a read-only file system, and spread across nodes where they can.

The network policies need a network plugin that enforces them, such as Calico or Cilium. Without one, the sandbox still holds no secrets and takes runs only from callers that send the sandbox token.

Each worker renders one document at a time, so the number of workers is the number of documents rendered in parallel. Set the counts in values.yaml and run helm upgrade (see upgrade):

worker:
replicas: 6
api:
replicas: 3

Or let Kubernetes scale them on CPU, which needs the metrics server:

worker:
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10

Every API pod can serve every request. People editing the same template in Studio’s visual editor share one live session, and the proxy sends all of them to the same API pod.

Workspaces share the workers fairly; see how workspaces share workers. All the pods of one release use one database, so they count as one installation.

The configuration reference describes every setting. In the chart, they go in these places:

Setting In values.yaml
PUBLIC_URL publicUrl
STORAGE_DRIVER, OBJECT_STORAGE_*, STUDIO_FILE_ORIGINS storage
AUTH_EMAIL_FROM, ENTRA_TENANT_ID, ENTRA_CLIENT_ID signIn
RENDER_RETENTION_DAYS, RENDER_TIMEOUT_MS, SCRIPT_ENV, and the others settings
WORKER_CLOSE_GRACE_MS, WORKER_STOP_GRACE_PERIOD worker.closeGraceMs, worker.terminationGracePeriodSeconds
TRUSTED_PROXY_RANGES proxy.trustedProxyRanges
Memory limits each component’s resources
Advanced settings api.extraEnv, worker.extraEnv
settings:
RENDER_RETENTION_DAYS: "90"
worker:
extraEnv:
- name: RENDER_MAX_PAGES
value: "100"

A variable in extraEnv replaces the chart’s own setting of the same name.

The settings that pick the certificate and the host ports do not apply: your ingress handles both.

Pods read the Secret as they start. After you change it, restart them: kubectl --namespace typefold rollout restart deployment.

The API limits requests, including sign-in attempts, per client address. The proxy takes the client’s address from X-Forwarded-For only for requests from proxy.trustedProxyRanges, which by default are the private address ranges where in-cluster ingress controllers run. Make sure your ingress controller sets X-Forwarded-For to the real client, and if a CDN or a load balancer sits in front of it, configure the controller to trust only that one.

  1. Back up the database and the bucket.

  2. Upgrade to the newest release, keeping your values:

    Terminal window
    helm upgrade typefold oci://registry.typefold.dev/typefold-helm \
    --namespace typefold --values values.yaml --wait --timeout 15m
  3. Check the release notes for one-off steps. Where they show a docker compose run command, run it in an API pod instead: kubectl --namespace typefold exec deploy/typefold-api -c api -- node dist/merge-reports.js.

The upgrade runs the migrations first. The API may write renders in a format only its own release’s worker understands, so the old workers stop before the new ones start, and new API pods start only once a new worker is ready. Renders wait in the queue meanwhile and none is lost. The API, Studio and the proxy are replaced one pod at a time, with no downtime.

To go back, run helm rollback typefold only to a release whose migrations the database already has; restore the database from before the upgrade otherwise.

On an upgrade, a worker finishes its current render first, for up to worker.closeGraceMs (75 seconds), and Kubernetes stops it after worker.terminationGracePeriodSeconds (90). If you raise RENDER_TIMEOUT_MS, raise both, each at least 15 seconds above the one before:

settings:
RENDER_TIMEOUT_MS: "120000"
worker:
closeGraceMs: 135000
terminationGracePeriodSeconds: 150

The API serves Prometheus metrics on port metrics and every worker on port http, both at /metrics. With the Prometheus Operator, set metrics.serviceMonitor.enabled: true to scrape them. See monitoring for the metrics and the alert rules.

Back up the PostgreSQL database and the bucket, and keep your Secret (or its values) apart from the backups. Nothing in the cluster itself needs a backup. Restore the database and the files from the same moment, as in where your data lives.

  • helm install stops with ... is required. A required value is missing; the message names it.
  • The migrations Job fails. Read its log: kubectl --namespace typefold logs -l app.kubernetes.io/component=migrations. Usually the database address or password is wrong, or the user cannot create tables.
  • Pods stay in ImagePullBackOff. The pull secret is missing or holds another license key. Check it with helm registry login registry.typefold.dev -u license.
  • API pods stay in Init. They wait for a worker of the same release. Read the worker’s log: kubectl --namespace typefold logs deploy/typefold-worker.
  • /health answers 503. Its unavailable list names what the API cannot reach, database or redis.
  • The visual editor keeps reconnecting. The ingress closes idle WebSocket connections: raise its timeouts to at least a minute, as in step 4.