Skip to content

Installing Flux CD on Kubernetes for GitOps reconciliation

Bootstrap Flux CD on a Kubernetes cluster with the flux CLI, multi-tenant Kustomizations, GPG-verified commits, and the source-controller / kustomize-controller pattern.

You are picking Flux over Argo CD because the team wants a controller-only GitOps system with no UI to secure, no admin password to rotate, and the entire control surface lives in Git. The default flux bootstrap command works on a fresh cluster; this article is the production install — multi-tenant from the start, GPG-verified commits if your org allows, source-of-truth in a private repo, and observability that surfaces a stuck reconciliation before someone notices the app is on yesterday’s image.

How to verify

All Flux controllers should run in flux-system:

kubectl -n flux-system get deploy
kubectl -n flux-system get pods

The bootstrap repository should be tracked as a GitRepository source:

flux get sources git
flux get sources git -A

Kustomizations should reconcile cleanly:

flux get kustomizations -A

A reconcile should be triggerable on demand:

flux reconcile source git flux-system
flux reconcile kustomization flux-system

What’s happening

Flux is split into five controllers, each handling one resource kind: source-controller (clones Git/Helm/OCI/S3 sources), kustomize-controller (applies Kustomize overlays from sources), helm-controller (applies HelmReleases), notification-controller (events out to Slack, GitHub status, etc.), and image-automation-controller + image-reflector-controller (image tag automation; see flux-image-automation).

The bootstrap process is what most teams underestimate. flux bootstrap github ... (or gitlab, gitea, bitbucket-server, or generic git) creates a Git repository (or uses an existing one), commits the Flux installation manifests into it, installs Flux into the cluster pointing at that repo, and the controllers begin reconciling. After bootstrap, the cluster’s truth lives in clusters/<name>/flux-system/. You add applications by committing manifests anywhere in the repo and referencing them with a Kustomization.

The procedure

  1. Install the CLI.

    curl -s https://fluxcd.io/install.sh | sudo bash
    flux --version
  2. Generate a Personal Access Token with repo scope for GitHub (or equivalent for your provider) and export it:

    export GITHUB_TOKEN=ghp_xxx
    export GITHUB_USER=example-org
  3. Bootstrap against a private repo. This creates the repo if missing, commits Flux manifests, and installs Flux:

    flux bootstrap github \
      --owner=$GITHUB_USER \
      --repository=gitops \
      --branch=main \
      --path=clusters/prod \
      --personal=false \
      --private=true \
      --components-extra=image-reflector-controller,image-automation-controller \
      --network-policy=true

    The --path is critical — Flux treats clusters/prod as the root for this cluster. Add clusters/staging, clusters/dev for other environments and bootstrap each from its own branch or tag.

  4. Layer multi-tenant directory structure. A clean Flux repo looks like:

    ├── clusters/
    │   ├── prod/
    │   │   ├── flux-system/      # bootstrap output
    │   │   ├── infrastructure.yaml
    │   │   └── apps.yaml
    │   └── staging/
    ├── infrastructure/
    │   ├── controllers/
    │   │   ├── cert-manager.yaml
    │   │   └── ingress-nginx.yaml
    │   └── configs/
    └── apps/
        ├── base/
        │   └── checkout/
        └── overlays/
            ├── prod/
            └── staging/

    clusters/prod/infrastructure.yaml declares a Kustomization pointing at ./infrastructure/controllers, and clusters/prod/apps.yaml points at ./apps/overlays/prod.

  5. Enable cluster-side commit verification. If your team signs commits with GPG, configure Flux to refuse unsigned ones:

    apiVersion: source.toolkit.fluxcd.io/v1
    kind: GitRepository
    metadata:
      name: flux-system
      namespace: flux-system
    spec:
      interval: 1m
      url: ssh://git@github.com/example-org/gitops
      ref: { branch: main }
      verify:
        mode: head
        secretRef:
          name: gpg-trusted-keys

    The gpg-trusted-keys Secret contains armored public keys; commits signed by any of them are accepted.

  6. Wire notifications to Slack/GitHub. Flux emits Kubernetes Events and can route them to external endpoints:

    apiVersion: notification.toolkit.fluxcd.io/v1beta3
    kind: Provider
    metadata:
      name: slack
      namespace: flux-system
    spec:
      type: slack
      channel: ops
      secretRef:
        name: slack-webhook
    ---
    apiVersion: notification.toolkit.fluxcd.io/v1beta3
    kind: Alert
    metadata:
      name: kustomizations
      namespace: flux-system
    spec:
      providerRef: { name: slack }
      eventSeverity: error
      eventSources:
        - kind: Kustomization
          name: '*'

    Now any failed reconcile shows up in #ops — that is your “reconcile-stuck” alert.

Operational notes

  • flux bootstrap is idempotent. Re-running it updates Flux to the version of the CLI you used. Pin the CLI in CI so bootstraps are reproducible.
  • The kustomize-controller depends on the API server. A pinned interval of 1m means a slow API server adds latency to every reconcile. Increase the interval for low-priority Kustomizations to reduce API server pressure.
  • HelmReleases need a HelmRepository source. The helm-controller does not fetch directly; it requires a source-controller-managed HelmRepository. See flux-helm-releases-controllers.
  • postBuild substitutions are not vault. The Kustomization postBuild.substitute block lets you inject variables, but the result is checked into the cluster and visible in events. Use SOPS or external-secrets for actual secrets.
  • Network policies generated by bootstrap can lock out kubectl. --network-policy=true writes deny-by-default policies into flux-system. They restrict in-cluster talk only; kubectl from outside still works, but pod-to-pod traffic into flux-system from anywhere else is blocked. Verify before you commit changes that depend on cross-namespace calls.

Stack Harbor stands up Flux installs on customer clusters with the directory layout, the GPG verification, the SOPS secret pipeline, and the notification routing all in place — the goal is a cluster where kubectl edit on critical resources is impossible because every change goes through Git. See how we deliver that within managed Kubernetes operations.