Kubernetes: wardn-standard
Install Wardn for a team, with several replicas on a Postgres you provide.
wardn-standard is the production install. It runs three server replicas, each running every role, and two web app replicas, on a Postgres that you run or rent. The replicas coordinate through the database, so there is no queue, cache or broker to run beside it. Read Self-hosting first for what each part does.
The chart and wardn-tiny share their templates. The differences are the defaults:
wardn-tiny | wardn-standard | |
|---|---|---|
| Server replicas | 1 | 3, spread across nodes where possible |
| Web replicas | 1 | 2 |
| Postgres | bundled | external |
| Keys | generated by the chart | your Secrets |
| Gateway Service | ClusterIP | LoadBalancer |
| PodDisruptionBudget | off | on, one pod at a time |
| Server resources | 100m CPU and 256 MiB requested, 1 GiB limit | 250m CPU and 512 MiB requested, 2 GiB limit |
Before you start
You make three things before the install: a database, the keys, and a name for the gateway.
A database
Postgres 14 or newer, reachable from the cluster, with a database and a user that can create tables. The server migrates the schema when it starts. Postgres covers sizing, TLS and poolers.
Put the password in a Secret:
kubectl create namespace wardn
kubectl -n wardn create secret generic wardn-db --from-literal=password='...'The chart builds the connection URL from the host, port, user, database and this password, so the password must not contain @ : / ? #. If it does, put a whole connection URL in a Secret instead and name it with postgres.external.urlSecretRef.
The keys
Two values protect the install, and both must survive every upgrade and reinstall:
- The Better Auth secret (at least 32 characters). The web app signs sessions with it and the server checks them, so both must have the same value.
- The secret store's master key, an age key. It wraps the keys that encrypt the secrets Wardn stores. Lose it and those secrets cannot be opened.
kubectl -n wardn create secret generic wardn-keys \
--from-literal=better-auth-secret="$(head -c 48 /dev/urandom | base64 | tr -d '\n=+/')" \
--from-literal=secret-master-key="$(age-keygen | grep AGE-SECRET-KEY)"Keep a copy outside the cluster (Backup and restore). If you would rather the chart make them, set secrets.generate=true: a hook Job creates the Secret <release>-secrets on the first install and never replaces it.
A name for the gateway
Operators in your clusters dial the gateway over mutual TLS on port 8443. Pick a DNS name for it, such as gateway.example.com. After the install you point it at the gateway Service's load balancer. Nothing in front of the gateway may end TLS. The gateway explains why and how certificates work.
Install
Write the values to a file so upgrades reuse them:
publicUrl: https://wardn.example.com
ingress:
enabled: true
className: nginx
host: wardn.example.com
tlsSecret: wardn-web-tls
secrets:
betterAuth: {name: wardn-keys}
masterKey: {name: wardn-keys}
postgres:
external:
host: db.example.com
passwordSecretRef: {name: wardn-db}
gateway:
hosts: [gateway.example.com]
advertise: gateway.example.com:8443helm install wardn oci://ghcr.io/future-pirate-king/charts/wardn-standard \
--namespace wardn --values values.yaml --wait --timeout 10mThe keys in wardn-keys are read from better-auth-secret and secret-master-key, and the database password from password, unless you name other keys with .key. Helm chart values lists every value.
After the install
Point the gateway name at its Service
kubectl -n wardn get service wardn-wardn-standard-gatewayCreate a DNS record for gateway.example.com that points at the EXTERNAL-IP. Use gateway.service.annotations to ask your cloud for a particular kind of load balancer, for example an internal one or a network load balancer. The Service uses externalTrafficPolicy: Local.
Check it is ready
kubectl -n wardn rollout status deploy/wardn-wardn-standard-server
kubectl -n wardn exec deploy/wardn-wardn-standard-server -- wget -qO- http://localhost:8080/api/v1/readyThe first replica to start runs the migrations; the others wait for them. /api/v1/ready answers once the database answers, every migration has run and the web app has created its sign-in tables, which its init container does before it starts.
Sign up and connect a cluster
Create the first owner, open the setup link it prints and set a password. Then make an API token and connect a cluster:
export WARDN_API_URL=https://wardn.example.com
export WARDN_TOKEN=wrd_...
wardn cluster connect --create --name prod-eu-1 --tier production \
--gateway-url https://gateway.example.com:8443How the replicas share the work
- API. Every replica answers API requests behind the
wardn-serverService. - Gateway. Each cluster's operator is held by exactly one replica, chosen by hashing over the live replicas and kept with a lease in the database. An operator that reaches a replica that does not hold its cluster is refused and reconnects. If a replica dies, its clusters move to another within the lease time (15 seconds by default). A terminal or log stream that reaches a replica not holding the cluster is passed on to the one that does. See Failures and offline clusters.
- Controller. Periodic tasks run on one replica at a time.
- Worker. Background work is taken from a queue in Postgres, by any replica.
Roll-outs replace one replica at a time and wait for the new one to be ready (maxUnavailable: 0). The PodDisruptionBudget keeps all but one replica up during node drains.
Connection pooling
Each replica opens up to 20 connections to Postgres by default, and the web app opens a few more. With three replicas, plan for about 100 connections. To put PgBouncer (or another pooler, in transaction mode) in front of the request path:
postgres:
pooler:
enabled: true
host: pgbouncer.example.com
port: 6432Requests then go through the pooler, and the server keeps a direct connection to the database for LISTEN, leader leases and migrations. Postgres explains the sizes.
Pass other settings
The chart sets only the settings it has values for. Pass any other as an ordinary Kubernetes env entry, with secrets read from a Secret:
server:
extraEnv:
- {name: WARDN_PUBLIC_URL, value: https://wardn.example.com}
- {name: WARDN_APPLY_TIMEOUT, value: 15m}web.extraEnv does the same for the web app. GitHub App uses this to connect GitHub.
Read replica
To read the lists from a hot standby of your database:
helm upgrade wardn oci://ghcr.io/future-pirate-king/charts/wardn-standard -n wardn --reuse-values \
--set postgres.readReplica.enabled=true \
--set postgres.readReplica.host=standby.db.example.comYou always see your own changes, and a standby more than postgres.readReplica.maxLag behind (5 seconds by default) serves nothing until it catches up. See Postgres for how it works and what it costs.
Object storage
To keep blobs in S3, Cloudflare R2, MinIO or Cloud Storage instead of Postgres, set providers.objectstore and the objectStore values. The bucket, region, endpoint, path style, the Secret that holds a static key and the sweep settings each have a value; see Object storage for examples and Helm chart values for the list.
Upgrade and uninstall
helm upgrade wardn oci://ghcr.io/future-pirate-king/charts/wardn-standard -n wardn --values values.yaml --version 0.2.0Read Upgrading first, and take a database backup. helm uninstall wardn -n wardn removes the workloads. Your database, your Secrets and any Secret the chart generated stay.