Hosting
TestCraft ships as a Helm chart at infrastructure/helm/testcraft. It runs the API, the web app, the gateway, the docs and everything they depend on (Postgres, Redis, RabbitMQ, MinIO, Keycloak, GlitchTip) plus Prometheus, Alertmanager, Grafana, Loki and Tempo. testcraft.pro runs it on a single-node k3s cluster.
Prerequisites
Section titled “Prerequisites”- A Kubernetes cluster with
kubectlaccess. The chart is tested on k3s. - Helm 3
- cert-manager installed in the cluster
- DNS records for the web,
auth.andglitchtip.hosts pointing at the cluster
Values files
Section titled “Values files”| File | Purpose |
|---|---|
values.yaml |
Chart defaults |
values.production.yaml |
testcraft.pro: GHCR images, Let’s Encrypt, resource limits |
values.local.yaml |
The local kind cluster (see Local cluster) |
values.secrets.yaml.example |
Template for values.secrets.yaml, which holds every credential |
Your own domain
Section titled “Your own domain”The defaults point at testcraft.pro. For another domain, set:
keycloak.hostname,platform.webBaseUrl,platform.glitchtipBaseUrlandplatform.alertFromEmail. The gateway routesauth.andglitchtip.traffic by these hosts, and the API trusts tokens issued bykeycloak.hostname.tls.dnsNames,secrets.corsAllowedOriginsandsecrets.minioPublicEndpoint.- The
testcraft-webclient’s redirect URIs and web origins ininfrastructure/shared/keycloak/realm.json. Keycloak imports the realm only on its first start, so after that change them in the Keycloak admin console.
The web image has its API and Keycloak URLs built in, so build your own from apps/web/Dockerfile with the VITE_* build arguments instead of using the published one.
First install
Section titled “First install”-
Copy the secrets template and fill it in:
Terminal window cp infrastructure/helm/testcraft/values.secrets.yaml.example \infrastructure/helm/testcraft/values.secrets.yaml -
Create the
testcraftnamespace with Helm’s ownership labels. The chart manages the namespace itself, so don’t pass--create-namespace:Terminal window kubectl create namespace testcraftkubectl label namespace testcraft app.kubernetes.io/managed-by=Helmkubectl annotate namespace testcraft meta.helm.sh/release-name=testcraft meta.helm.sh/release-namespace=testcraftOn the production k3s host,
TESTCRAFT_DEPLOY_ENV=production just prod::bootstrapdoes this. -
Install the chart:
Terminal window helm dependency build infrastructure/helm/testcrafthelm upgrade --install testcraft infrastructure/helm/testcraft \--namespace testcraft \-f infrastructure/helm/testcraft/values.production.yaml \-f infrastructure/helm/testcraft/values.secrets.yaml
The API applies database migrations when it starts. On every later upgrade, the migrator job runs them as a pre-upgrade hook, before the new API pods start.
-
tls.provider: letsencrypt(production) issues certificates fortls.dnsNamesfrom Let’s Encrypt. It needstls.acmeEmail, and the bundled ingress-nginx answers the HTTP-01 challenge. -
Any other provider signs certificates with a CA you supply as the
testcraft-ca-tlssecret in the namespace:Terminal window kubectl -n testcraft create secret tls testcraft-ca-tls --cert=ca.pem --key=ca-key.pem
Deploying testcraft.pro
Section titled “Deploying testcraft.pro”Deploys run on a self-hosted GitHub Actions runner on the production host, in the production environment:
- A push to
mainbuilds and publishes images for the apps it touches. When theAUTO_DEPLOY_PRODUCTIONrepository variable istrue, it also deploys them; otherwise run the app’s CI workflow by hand. infra-deployapplies chart changes (infrastructure/helm/**,infrastructure/shared/**).infra-deploy-versiondeploys one app at a given tag: a release (v1.2.3) or a commit SHA.
The same deploys can be run on the host. The prod:: recipes refuse to run unless TESTCRAFT_DEPLOY_ENV=production is set, so they can’t hit another cluster by accident:
TESTCRAFT_DEPLOY_ENV=production just prod::deploy # whole chartTESTCRAFT_DEPLOY_ENV=production just prod::deploy-app api v1.2.3 # one app at a tagdeploy-app checks that the image exists in GHCR before it deploys, and rolls the release back if the new pods don’t become ready.
Backups and monitoring
Section titled “Backups and monitoring”- Postgres and MinIO are backed up into MinIO every night, and a restore of the latest Postgres backup is verified afterwards. Set the schedules and retention under
backups. Setbackups.offsiteand theoffsiteBackup*secrets to copy them to S3-compatible storage outside the cluster. - Grafana is served at
/grafanaon the web host, with dashboards for the API, Postgres, Redis, RabbitMQ and the cluster. - Alertmanager emails alerts to
secrets.alertEmailTo. Each alert links to its section in the alert runbooks.
Local cluster
Section titled “Local cluster”just kind::up runs the chart on a local kind cluster with production-like settings. It needs Docker, kind, kubectl, Helm, yq and mkcert with its root CA installed (mkcert -install).
The recipe creates the cluster if it’s missing, installs cert-manager and issues TLS from your mkcert CA. Then it builds every image and installs the chart with values.local.yaml. On the first run it writes random credentials to the gitignored values.local.secrets.yaml.
just kind::up # everything, from nothingjust kind::deploy api # rebuild and redeploy one app (api includes the migrator)just kind::deploy web gateway # several appsjust kind::destroy # delete the namespace, its data and its volumes| Service | URL |
|---|---|
| Web | https://testcraft.localhost |
| Keycloak | https://auth.testcraft.localhost |
Mailpit isn’t exposed through the gateway. Forward its port and open http://localhost:8025:
kubectl --context kind-testcraft-prod-local -n testcraft port-forward svc/mailpit 8025