Kubernetes · GitOps

Who Deploys the Deployer? Terraform-Bootstrapped FluxCD

Terraform installs the six Flux controllers on a fresh cluster and seeds per-cluster GitOps config from templates; Flux then manages the cluster and itself.

  • FluxCD
  • Terraform
  • Kustomize
  • Helm
  • GitHub App
  • Workload Identity
  • External Secrets
  • Istio

// Overview

The bootstrap workflow generates a per-cluster config directory from shared templates (pruning optional parts by feature flag), opens an auto-merged PR, then runs Terraform to bootstrap Flux and patch controllers. A lock file stops later runs regenerating customised config. Controllers authenticate to Git with a GitHub App and to the cloud with workload identity.

// The problem

Without GitOps, deployments are manual kubectl with no audit trail. But Flux cannot deploy itself, so a repeatable bootstrap is needed that never clobbers team customisations on re-run.

// Flow

Who Deploys the Deployer? Terraform-Bootstrapped FluxCD flow1. Trigger → 2. Prepare → 3. Lock check → 4. Generate config → 5. PR to GitOps repo → 6. Terraform apply → 7. Controller patches → 8. Create lock → 9. Steady state01Trigger02Prepare03 · GATELock check04Generate config05PR to GitOps repo06Terraform apply07Controller patches08Create lock09Steady state
  1. Triggerafter autoscaling, or manually; concurrency per team and environment
  2. Prepareread 20+ Vault values, resolve six controller identities
  3. Lock check gateif a bootstrap lock exists, skip config generation
  4. Generate configcopy template base, prune optional directories, substitute variables
  5. PR to GitOps repoauto-merged; repeated for the HA secondary
  6. Terraform applymatrix over lower, upper, primary, secondary
  7. Controller patchesconcurrency, resource limits, affinity, identity annotations
  8. Create lockcommitted per cluster
  9. Steady stateFlux reconciles every 60 seconds; rotation flows through Vault

// Design decisions & guardrails

  • Bootstrap lock: the first run generates, later runs only reconcile controller patches; delete the lock to regenerate.
  • Template system with conditional pruning by feature flag (HA, monitoring, mesh mode).
  • Git authentication via GitHub App, with PAT fallback gated per cluster by a Vault key.
  • Workload identity on every controller instead of static cloud credentials.
  • Controller settings are Terraform patches rather than a template so they can be reconciled on every run.
  • HA uses separate state per cluster and separate key suffixes for the secondary.

// Outcome

Six controllers per cluster, reconciling every 60 seconds, with no hand-run bootstrap.

// Related