This repository demonstrates GitOps using FluxCD with multiple clusters (staging/production) and different deployment methods:
- Kustomize deployment with podinfo
- Helm deployment with Redis
- OCI deployment with Grafana
- Helm Chart deployment with Prometheus
├── apps
│ ├── base
│ │ ├── grafana
│ │ ├── podinfo
│ │ ├── prometheus
│ │ └── redis
│ ├── production
│ └── staging
├── infrastructure
│ ├── configs
│ └── controllers
└── clusters
├── production
└── staging
- A Kubernetes cluster v1.28 or newer
- GitHub account and personal access token
- Flux CLI installed:
brew install fluxcd/tap/flux # or curl -s https://fluxcd.io/install.sh | sudo bash
- Kubernetes kind installed if using multi cluster setup:
brew install kind
- Simple web application
- Deployed using Kustomize
- Different configurations for staging/production
- In-memory data store
- Deployed using Helm
- Configured with different persistence settings per environment
- Monitoring dashboard
- Deployed using OCI artifacts
- Different datasource configurations per environment
- Monitoring and alerting toolkit
- Deployed using Helm Chart from prometheus-community
Environment variables:
export GITHUB_TOKEN=<your-token>
export GITHUB_USER=<your-username>
export GITHUB_REPO=release-fluxcd-demo
# Bootstrap staging
flux bootstrap github \
--owner=${GITHUB_USER} \
--repository=${GITHUB_REPO} \
--branch=main \
--personal \
--path=clusters/staging
# Bootstrap production
flux bootstrap github \
--owner=${GITHUB_USER} \
--repository=${GITHUB_REPO} \
--branch=main \
--personal \
--path=clusters/production
For multi cluster setup we will add context
to the bootstrap command:
Create kind clusters:
kind create cluster --name staging
kind create cluster --name production
Make sure to set the context for the clusters:
kubectl config rename-context kind-staging staging
kubectl config rename-context kind-production production
flux bootstrap github \
--context=staging \
--owner=${GITHUB_USER} \
--repository=${GITHUB_REPO} \
--branch=main \
--personal \
--path=clusters/staging \
flux bootstrap github \
--context=production \
--owner=${GITHUB_USER} \
--repository=${GITHUB_REPO} \
--branch=main \
--personal \
--path=clusters/production \
apps/base/podinfo
: Kustomize manifests for podinfoapps/base/redis
: Helm release configuration for Redisapps/base/grafana
: OCI image configuration for Grafanaapps/base/prometheus
: Helm Chart configuration for Prometheus
apps/staging
: Staging-specific configurationsapps/production
: Production-specific configurations
infrastructure/controllers
: Common controllers (ingress-nginx, cert-manager)infrastructure/configs
: Shared configurations
Watch the deployments:
# Get all Flux resources
flux get all
# Watch Helm releases
flux get helmreleases --all-namespaces --watch
# Watch kustomizations
flux get kustomizations --watch