Skip to content

202511132150 Consolidated CI

After migrating in the kubernetes components and the terraform modules, wrapper scripts were introduced through package.json files, which provides pnpm and turbo to execute + orchestrate it.

After 202510041935 Deploying Via FluxCD and introducing Kustomize + Kubectl Scripts 202511082153 Turborepo + Kustomize + Kubectl ❤️, the CI felt a little too scattered.

Each module had its own CI step:

  1. One for build, testing the app
  2. One for building and publishing docker images for apps
  3. One for executing terraform plan and apply if there were changes
  4. One for running kustomize + kubectl diff

It was kind of strange to have all these jobs run in sync. One major pain point I had was that each step needed a Tailscale Client setup and often failed. I suspected that there is some kind of limitation, somewhere that implicitly prevents too many tailscale clients to run int he CI. Or perhaps there is a rate limiting somewhee. I don’t know. I am just speculating.

What became clear was that Turbo can also orchestrate and execute tasks in parallel. Orchestration can be done through the turbo.jsonc file, informing which step had dependencies while turbo itself can execute tasks in parallel, as long as they are executed and passed in.

Take this executable command as an example

Terminal window
pnpm turbo build build:docker tf:plan k8s:diff --affected

Is basically saying execute the scripts for 1) building apps, 2) building docker images 3)running terraform plan 4)executing a kubernetes diff for only affected apps.

Turborepo will then run everything in parallel, and orchestrate the appropriate execution based on the dependencies defined in turbo.json.

Neat.

So now my CI just executes a simple step that runs all these commands for the various components within the homelab repo

  1. The apps
  2. The terraform changes
  3. The kubernetes diff
- name: Turborepo build, plan and change affected apps, terraform modules and k8s configs
run: pnpm turbo run build build:docker tf:fmt:check tf:plan:output k8s:diff:apps:ci k8s:diff:infra:ci --affected
working-directory: ./forge