Flux v2 Fundamentals

This repository acts as a foundational framework for managing multi-tenant Kubernetes clusters through Git and Flux v2. https://github.com/fluxcd/flux2-multi-tenancy/

Key Concepts:

  • Platform Admin: This user manages the overall cluster resources and tenants. They have cluster admin access, manage the fleet Git repository, and onboard new tenants.
  • Tenant: Tenants have admin access to their assigned namespaces and manage their applications within those namespaces. They utilize GitRepositories and Kustomizations for deployment, and HelmRepositories and HelmReleases for managing application releases.

Workflow:

  1. Bootstrapping:

  2. Tenant Onboarding:

  3. Tenant Management:

Repository Structure:

  • clusters: Contains Flux configuration per cluster.
  • infrastructure: Contains common infrastructure tools like admission controllers, CRDs, and cluster-wide policies.
  • tenants: Contains namespaces, service accounts, role bindings, and Flux custom resources for registering tenant repositories. https://github.com/fluxcd/flux2-multi-tenancy/

Tenant Repository Structure:

  • base: Contains HelmRepository and HelmRelease manifests.
  • staging: Contains HelmRelease Kustomize patches for deploying pre-releases on the staging cluster.
  • production: Contains HelmRelease Kustomize patches for deploying stable releases on the production cluster.

CI/CD:

Security Considerations:

Examples:

Top-Level Directory Explanations

clusters/ - This directory contains configuration and scripts for managing Kubernetes clusters.

clusters/production/ - This directory contains configuration and scripts for managing the production Kubernetes cluster.

clusters/production/flux-system/ - This directory contains configuration and scripts for the FluxCD system in the production cluster.

clusters/staging/ - This directory contains configuration and scripts for managing the staging Kubernetes cluster.

clusters/staging/flux-system/ - This directory contains configuration and scripts for the FluxCD system in the staging cluster.

infrastructure/ - This directory contains infrastructure-related configuration files and scripts.

infrastructure/kyverno-policies/ - This directory contains the actual policy files for Kyverno.

infrastructure/kyverno/ - This directory contains configuration files and scripts for Kyverno, an open-source Kubernetes policy engine.

scripts/ - This directory contains scripts used for various tasks, such as automation and deployment.

tenants/ - This directory contains configuration and scripts for managing tenants, which are separate namespaces or projects within the Kubernetes cluster.

tenants/base/ - This directory contains configuration and scripts for the base tenant.

tenants/base/dev-team/ - This directory contains configuration and scripts for the development team within the base tenant.

tenants/production/ - This directory contains configuration and scripts for the production tenant.

tenants/staging/ - This directory contains configuration and scripts for the staging tenant.