Skip to content
/ flux-playground Public template

Manage multiple K8s clusters with Flux, Kustomize and Helm.

Notifications You must be signed in to change notification settings

YuKitAs/flux-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Flux Playground

A minimal example to show how to manage multiple K8s clusters with Flux, Kustomize and Helm.

  • Flux version: 0.26.3

  • Create K8s clusters for staging and production e.g. with kind. Set kubectl context flux-staging and flux-prod in ~/.kube/config for namespace flux-system.

  • Export GITHUB_TOKEN and GITHUB_USER

  • Check prerequisites with flux check --pre

  • Bootstrap Flux for staging/production:

    $ flux bootstrap github --context=flux-staging --owner=${GITHUB_USER} --repository=flux-playground --branch=main --personal --path=clusters/staging
    $ flux bootstrap github --context=flux-prod --owner=${GITHUB_USER} --repository=flux-playground --branch=main --personal --path=clusters/prod

    It will commit the component and sync manifests in clusters/{staging,prod}/flux-system/ directory in the GitHub repository, and create a deploy key with read-only access on GitHub in order to pull changes inside the corresponding cluster.

  • List HelmRelease objects:

    $ flux get helmreleases --all-namespaces
  • Watch Kustomization statuses:

    $ flux get kustomizations -w
  • Clean up Flux components, custom resources and namespace:

    $ flux uninstall --namespace=flux-system [--dry-run]

Project structure:

├── apps
│   ├── base
│   │   └── podinfo
│   │       ├── kustomization.yaml
│   │       ├── namespace.yaml
│   │       └── release.yaml
│   ├── prod
│   │   ├── kustomization.yaml
│   │   └── podinfo-patch.yaml
│   └── staging
│       ├── kustomization.yaml
│       └── podinfo-patch.yaml
├── clusters
│   ├── prod
│   │   ├── apps.yaml
│   │   └── infrastructure.yaml
│   └── staging
│       ├── apps.yaml
│       └── infrastructure.yaml
├── infrastructure
│   ├── kustomization.yaml
│   ├── nginx
│   │   ├── kustomization.yaml
│   │   ├── namespace.yaml
│   │   └── release.yaml
│   └── sources
│       ├── bitnami.yaml
│       ├── kustomization.yaml
│       └── podinfo-source.yaml

About

Manage multiple K8s clusters with Flux, Kustomize and Helm.

Topics

Resources

Stars

Watchers

Forks