← All insightsIntegration

How to use Flux CD with Kubernetes

CodeWizard Engineering · 30 April 2025 · 3 min read · Intermediate

Flux CD and Kubernetes are a common pairing in a modern DevOps stack. Here is how they fit together and a practical way to wire them up.

Where Flux CD fits

Flux is a set of Kubernetes controllers that keep clusters in sync with sources like Git, Helm repositories and OCI artifacts, with first-class Kustomize and Helm support.

yaml
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata: { name: apps, namespace: flux-system }
spec:
  interval: 1m
  url: https://github.com/acme/deploy
  ref: { branch: main }
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata: { name: web, namespace: flux-system }
spec:
  interval: 5m
  path: ./apps/web
  prune: true
  sourceRef: { kind: GitRepository, name: apps }

Where Kubernetes fits

Kubernetes is a container orchestrator: you declare the desired state of your workloads in YAML and controllers continuously reconcile the cluster toward it, handling scheduling, scaling, healing and networking.

yaml
apiVersion: apps/v1
kind: Deployment
metadata: { name: web }
spec:
  replicas: 3
  selector: { matchLabels: { app: web } }
  template:
    metadata: { labels: { app: web } }
    spec:
      containers:
        - name: web
          image: ghcr.io/acme/web:1.0
          ports: [{ containerPort: 3000 }]
          resources:
            requests: { cpu: 100m, memory: 128Mi }
            limits:   { cpu: 500m, memory: 256Mi }
          readinessProbe:
            httpGet: { path: /healthz, port: 3000 }
---
apiVersion: v1
kind: Service
metadata: { name: web }
spec:
  selector: { app: web }
  ports: [{ port: 80, targetPort: 3000 }]

Making them work together

  • Set prune:true and sensible intervals per Kustomization
  • Use the notification controller to alert on reconcile failures
  • Set requests/limits and use the HorizontalPodAutoscaler for elastic workloads
  • Separate config (ConfigMap) from secrets and mount them, don't bake them in

Want this pairing set up properly, with docs and handover? That is exactly the kind of work CodeWizard's embedded senior engineers do - and both Flux CD and Kubernetes have active community groups you can join for free.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult