Skip to content

Taskbase — Deployment Guide

Kind: reference

Overview

Taskbase consists of three services deployed to Kubernetes via Flux CD:

  • platform-tasks-api — Go REST API (harbor.prod.skatzi.com/skatzi/platform-tasks-api)
  • platform-tasks-ui — React SPA served by nginx (harbor.prod.skatzi.com/skatzi/platform-tasks-ui)
  • platform-tasks-mcp — the MCP server (harbor.prod.skatzi.com/skatzi/platform-tasks-mcp)

There are two environments: dev (tasks-dev namespace) and prod (tasks-prod namespace).

platform-tasks-ui: compression and caching

The UI container's nginx (ui/nginx.conf in the Taskbase repo) compresses and sets cache headers; the gateway in front of it (Cilium's Envoy-based shared-gateway) does neither (Taskbase PR #160):

  • gzip is on for responses of 1024 bytes or more: HTML, plus gzip_types JS, CSS, JSON, SVG and plain text, with gzip_vary on so caches key on Accept-Encoding.
  • /assets/* files carry a content hash in their names from Vite, so they are served with Cache-Control: public, max-age=31536000, immutable.
  • index.html, and the SPA fallback that serves it for every client-side route, is served with Cache-Control: no-cache, no-store, must-revalidate, so a new deployment shows up on the next load.

To check, take a bundle name from the page and ask for it with gzip:

curl -s https://taskbase.skatzi.com/ | grep -o '/assets/[^"]*\.js'
curl -sI -H 'Accept-Encoding: gzip' https://taskbase.skatzi.com/assets/<bundle>.js

The answer should show content-encoding: gzip and the immutable cache-control; the same request for / or any route such as /runners should show the no-cache policy.

Taskbase has three images, all in harbor.prod.skatzi.com/skatzi/: platform-tasks-api, platform-tasks-ui and platform-tasks-mcp. Flux deploys deploy/dev/ of the Taskbase repository to https://taskbase.dev.skatzi.com and deploy/prod/ to https://taskbase.skatzi.com. Every release goes to dev first and is promoted to prod automatically once dev has run it healthily (Taskbase PR #180). The "Deployment" section of the Taskbase repository's CLAUDE.md is the source of truth for this pipeline.


Deployment Flow

flowchart LR
    A(["Pull request merged to main"])

    subgraph REL ["Release · deploy-dev.yaml"]
        direction TB
        R1["release<br/>semantic-release tags vX.Y.Z"]
        R2["build<br/>api, ui and mcp images vX.Y.Z"]
        R3["update-deployment<br/>bump deploy/dev/"]
        R1 --> R2 --> R3
    end

    subgraph PROMO ["promote-prod"]
        direction TB
        P0{"AUTO_PROMOTE is false,<br/>or prod has this version or newer?"}
        P1["Wait up to 20 min for dev<br/>/api/version to report vX.Y.Z"]
        P2["Soak 15 min, every 30 s:<br/>version still vX.Y.Z, /healthz 200"]
        P3{"Newer release<br/>appeared?"}
        P4["Bump deploy/prod/<br/>chore: promote prod to vX.Y.Z"]
        PF["Job fails,<br/>Mattermost notice and Taskbase task"]
        PS(["Skip quietly"])
        P0 -- Yes --> PS
        P0 -- No --> P1 --> P2 --> P3
        P3 -- Yes --> PS
        P3 -- No --> P4
        P1 -- Timeout --> PF
        P2 -- Check fails --> PF
    end

    A --> R1
    R3 --> P0
    P4 --> F(["Flux deploys prod"])

CI on Branches and Pull Requests

.gitea/workflows/ci.yaml runs on every push to a branch other than main and on every pull request. Its jobs:

  • test-api and test-mcp: on Go 1.27, go build, go test and go vet for api/ (with a Postgres service, so the per-schema Postgres tests run) and for mcp/.
  • test-images (Test runtime images): kaniko builds all three images from their Dockerfiles without pushing them. The api and mcp images are also started, the api against a Postgres service, and must answer /api/health and /healthz. The ui image (ui/Dockerfile: a node:26-alpine builder that runs npm ci and npm run build, served by nginxinc/nginx-unprivileged:1.25-alpine) is only built, not started (Taskbase PR #662).
  • test-promote: the tests of the promotion script (promote-prod_test.sh).
  • test-deploy (Test database image gate): python3 -m unittest discover -s deploy -p 'test_*.py', which runs deploy/test_preupgrade.py. It fails while a Cluster's TARGET_VERSION in deploy/<env>/preupgrade/job.yaml differs from the tag of its imageName, or while Renovate's two managers (the imageName manager in renovate.json and the shared preset's # renovate: comment manager) stop finding the same dependency in the two files. See Database Image.
  • test-ui: for ui/ on Node 26, npm ci, then:
    • npm test: the node --test suites (src/*.test.js) and the vitest suites (src/*.test.jsx, src/diagramLayout/*.test.ts). These include the guard tests tokens.test.js, themes.test.js and Spacing.test.jsx.
    • npm run lint: eslint on src. Warnings, such as unused variables, do not fail the job.
    • npm run typecheck: tsc on the TypeScript in ui/src, which today is only ui/src/diagramLayout.
  • fitness: the fitness-function runner in fitness/, on Go 1.27 and Node 26. It restores its tools from Actions caches, so a run with a cache hit downloads nothing:

    • staticcheck: the version pinned in fitness/go.mod (a tool directive on honnef.co/go/tools v0.8.2, which is staticcheck 2026.2.2). The cache holds ~/.local/bin/staticcheck, keyed on the Go version, runner OS, architecture and the hash of fitness/go.mod and fitness/go.sum. On a miss, go install in fitness/ builds it.
    • UI tools such as ESLint (10.13.0 today): the versions locked in ui/package-lock.json. The cache holds ui/node_modules, keyed on the Node version, runner OS, architecture and the hash of the lock file. On a miss, npm ci in ui/ installs them.

    A failed install does not fail the job and is not cached: the partial install is removed, and the runner reports the missing tool as TOOL ERROR (exit 2), not as a rule violation. The pins change through fitness/go.mod and ui/package-lock.json, and the next run's cache key changes with them; a new Go or Node version in the workflow changes it too, so a toolchain bump such as Node 26 never reuses tools built by the old one. The job then runs: - cd fitness && go test ./...: the runner's own tests. - builds the runner and runs it. It checks each entry of fitness/expectations.json against its limit and exits 0 (pass), 1 (violation) or 2 (tool error or invalid file). Entries without a check are printed as NOT VERIFIED. The runner never changes a limit; limits change only through a pull request.

    This job is the Phase 2 pilot of ADR 0017. It stays a pilot until the gate review (task #1216) decides whether to keep it.

Node 26 in test-ui and fitness, and in the release job of deploy-dev.yaml, came with Taskbase PR #655 (read 2026-10-28).

All changes reach main through a pull request.


Release and Dev Deployment

.gitea/workflows/deploy-dev.yaml runs on every push to main:

  1. release — semantic-release tags vX.Y.Z from the conventional commits since the last tag. Its step Get latest version from git tags then sets the job's version output to the newest existing v* tag, not to the release semantic-release just made.
  2. build — kaniko builds and pushes the api, ui and mcp images tagged vX.Y.Z. The API bakes the version in through the VERSION build-arg of api/Dockerfile (-X main.version=vX.Y.Z).
  3. update-deployment — bumps the image tags in deploy/dev/ and pushes chore: update dev image tags to vX.Y.Z [skip ci]. Flux rolls dev out; the API runs its migrations at startup.
  4. promote-prod — see below.

Which commits make a release

.releaserc.json releases a breaking change (major), feat (minor), and fix, docs or perf (patch). Any other type, such as chore, ci, test or refactor, makes no release. So a non-breaking chore(deps) merge, which is how Renovate titles its pull requests, makes no release on its own: it reaches dev and prod only with the next release, made by a later feat, fix, docs or perf commit.

A push that makes no release still runs the rest of the workflow, because version is the newest existing tag and is never empty once a tag exists:

  • build rebuilds the three images from the pushed commit and pushes them under that existing tag.
  • update-deployment finds deploy/dev/ already on that tag and commits nothing, so Flux does not roll dev out.
  • promote-prod skips when deploy/prod/ already runs that tag.

Green build, update-deployment and promote-prod jobs after a merge therefore do not show that the merge was released or deployed. To check that a change is live, find the first vX.Y.Z tag that contains its commit (git tag --contains <commit>, or the chore: update dev image tags to vX.Y.Z [skip ci] commit after it on main), then check that dev or prod's /api/version reports that version or a newer one.

GET /api/version

An unauthenticated endpoint that returns the version the API was built with:

{"version":"v1.122.1"}

Local builds, without the build-arg, return dev.


Automatic Prod Promotion

The promote-prod job runs after update-deployment. Its script is .gitea/scripts/promote-prod.sh:

  • It skips when deploy/prod/ already has this version or a newer one, so prod is never downgraded.
  • It waits up to 20 minutes for https://taskbase.dev.skatzi.com/api/version to report the new version, that is, until Flux has rolled out the API and its migrations ran.
  • It then soaks for 15 minutes: every 30 s, /api/version must still report the version and dev's /healthz must return 200.
  • It shortens the soak to 5 minutes once prod has trailed for more than an hour, counted from when the oldest release newer than prod's was tagged, so a busy main does not keep prod behind.
  • It stops quietly if a newer release appears meanwhile; the newer release's run promotes instead.
  • On success it bumps the three image tags in deploy/prod/ and pushes chore: promote prod to vX.Y.Z [skip ci]. Flux then deploys prod.

Prod therefore runs a release about 15–35 minutes after the release is tagged: up to 20 minutes for dev to roll it out, then the 15-minute soak. Once prod has trailed for more than an hour, the short soak makes that about 5–25 minutes. A merged change gets there only in a release that contains it. A merge that makes a release is in that release, so it reaches prod in that time; a merge that makes none, such as a non-breaking chore(deps), waits for the next release, however long that takes. Migrations go to prod with the release, so every migration needs a working down migration.

Failure notice

If the wait or the soak fails or times out, or the promotion cannot be pushed, the job fails and posts Taskbase vX.Y.Z was **not** promoted to prod: <reason> — <run link> to Mattermost through the incoming webhook in the Actions secret MATTERMOST_WEBHOOK_URL. If the secret is unset, no notice is sent.

In the same failure, the step Report the failure to Taskbase runs .gitea/scripts/promote-prod.sh report <version> (task #1174, Taskbase PR #526). It posts a signed Promotion event for tasks-prod/taskbase on hetzner-mgmt, at revision vX.Y.Z, with the same reason and run link, to https://taskbase.skatzi.com/api/webhooks/flux. It signs with the Actions secret TASKBASE_FLUX_WEBHOOK_SECRET, which holds the same value as the API's FLUX_WEBHOOK_SECRET; if the secret is unset, no task is reported. The event also lists, as renovate_branches, the renovate/ branches merged between prod's release tag and this one, so the task follows up their dependency task. Taskbase makes one task per release; what it does with the event is in Post-merge failures.

Promote a release that failed the gate by hand, or let the next release promote.

Stopping promotion

Set the repository variable AUTO_PROMOTE=false (Settings → Actions → Variables) on the Taskbase repository. Delete it, or set any other value, to resume. Manual bumps of deploy/prod/ still work while it is off.


Database Image

deploy/dev/postgres-cluster.yaml (tasks-db) and deploy/prod/postgres-cluster.yaml (tasks-prod-db) pin spec.imageName (ghcr.io/cloudnative-pg/postgresql:<tag>). Source: the Database image paragraph in the Deployment section of the Taskbase repository's CLAUDE.md, and Taskbase PR #732 (task #3217), read 2026-11-15.

  • Moving the image. One Renovate pull request moves imageName and the gate Job's TARGET_VERSION (deploy/<env>/preupgrade/job.yaml) together. It is class stateful, and drain-class for tasks-prod-db (Renovate ADR §11). PostgreSQL majors are off in Renovate. test-deploy fails while the two differ.
  • The gate runs first. The platform's Flux Kustomization taskbase-<env>-preupgrade (task #3218) applies deploy/<env>/preupgrade/ from the same GitRepository, and taskbase-<env> depends on it, so a new image is applied only after the old version has been backed up and restored. How the gate works, how to read a pass and what to do when it fails: CloudNativePG: Taskbase's image gates.
  • Never in the same push as a CNPG operator chart change. The image gate and the operator gate share their scratch names ("Gates share their scratch names" in CloudNativePG: Operator upgrade gate).

Why the image is pinned, and which image each Cluster runs: CloudNativePG: PostgreSQL image.


API Metrics

The API serves Prometheus metrics on a second port, apart from its HTTP port 8080. Source: api/cmd/server/main.go and deploy/dev|prod/ in the Taskbase repository (task #1395, Taskbase PR #564, read 2026-10-21).

Endpoint GET /metrics on METRICS_PORT, default 9090. No HTTPRoute points at it, so it is reachable only inside the cluster
Metrics taskbase_gitea_sync_pending, the issue reconciler's pending count
When it runs Only with GITEA_TOKEN set. Without it there is no reconciler and no metrics server
Container port 9090, named metrics, in api-deployment.yaml. METRICS_PORT is not set, so the default applies
Service port metrics, 9090 → 9090, on the platform-tasks-api Service in tasks-dev and tasks-prod
Scrape ServiceMonitor platform-tasks-api (api-service-monitor.yaml) in each namespace: port metrics, path /metrics, every 1m, picked up by kube-prometheus-stack on hetzner-mgmt
Alert rule PrometheusRule platform-tasks-gitea-sync (deploy/prod/gitea-sync-prometheus-rule.yaml, label release: monitoring-kube-prometheus-stack) in tasks-prod only: alert TaskbaseGiteaSyncPending, severity: warning, when the pending count stays above zero for 30 minutes. Mattermost only, no incident. What it means: Pending metric (task #1422, Taskbase PR #587, read 2026-10-25)

To read it by hand, through the API server's Service proxy on hetzner-mgmt (no port-forward, so no local port that another cluster's forward could hold; see Read Alertmanager and Prometheus on a cluster):

kubectl --context admin@mgmt-cluster get --raw \
  /api/v1/namespaces/tasks-prod/services/http:platform-tasks-api:9090/proxy/metrics

The proxy connects from the API server to the pod, so a NetworkPolicy in tasks-prod that admits only Prometheus would refuse it (whether one exists was not checked for this page: the manifests are in the Taskbase repository). If the proxy fails, port-forward to a free local port in the foreground, read it from a second terminal, and stop the forward with Ctrl-C:

kubectl --context admin@mgmt-cluster -n tasks-prod port-forward svc/platform-tasks-api :9090
# Forwarding from 127.0.0.1:<port> -> 9090; then: curl -s http://127.0.0.1:<port>/metrics

The answer, here with 2 tasks pending (format from api/internal/task/reconcile_metrics_test.go; neither the command nor the answer was run against the cluster for this page):

# HELP taskbase_gitea_sync_pending Tasks whose Gitea issue needs a repair (missing, or its state differs from the task).
# TYPE taskbase_gitea_sync_pending gauge
taskbase_gitea_sync_pending 2

Rollback

Scenario Action
A release is bad on dev promote-prod does not promote it if dev stops reporting its version or /healthz fails during the soak; otherwise set AUTO_PROMOTE=false before the soak ends
A release is bad on prod Set AUTO_PROMOTE=false, then set the previous image tags in deploy/prod/ through a pull request. A release whose migration must be undone needs its down migration
Emergency rollback Manually patch the image tag in-cluster; Flux reverts it on the next reconcile unless deploy/prod/ changes too