Course contentsShow
← Cloud and Infrastructure
Lesson 1938 of 2,98941. FluxFree lesson

Multi-Tenancy with Flux

Implementing tenant isolation using namespaces, service accounts, and separate Git repositories.

Multi-Tenancy with Flux

What you'll learn: How to isolate workloads for multiple teams or customers within a single Flux-managed cluster using namespaces, service accounts, and separate Git repositories.

Why Multi-Tenancy Matters

Multi-tenancy allows multiple teams (tenants) to share a Kubernetes cluster while maintaining isolation and security boundaries. Think of it like an apartment building—each tenant has their own space with locked doors, but they share common infrastructure like elevators and utilities.

Core Isolation Strategies

Namespace Boundaries

Each tenant gets dedicated Kubernetes namespaces. Flux controllers reconcile resources within namespace constraints, ensuring Team A cannot accidentally deploy to Team B's namespace.

Service Account Segregation

Create separate service accounts per tenant with limited RBAC permissions. Flux uses these accounts to apply manifests, enforcing "least privilege" access. A tenant's service account can only modify resources in their designated namespaces.

Separate Git Repositories

The cleanest pattern: each tenant maintains their own Git repository. You configure separate GitRepository sources in Flux, each pointing to a different repo. This ensures complete separation of code, review processes, and access control at the Git level.

# tenant-a-source.yaml
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: tenant-a-repo
  namespace: flux-tenant-a
spec:
  url: https://github.com/org/tenant-a-config

Pattern in Practice

  1. Bootstrap Flux with admin privileges
  2. Create tenant namespaces (e.g., tenant-a, tenant-b)
  3. Deploy GitRepository and Kustomization resources per tenant
  4. Configure namespace-scoped RBAC for each tenant's service account
  5. Tenants commit to their repos; Flux syncs independently

Key Takeaway: Multi-tenancy in Flux combines Kubernetes-native isolation (namespaces, RBAC) with Git-level separation, enabling secure, scalable workload management for multiple teams or customers on shared infrastructure.