Skip to content

gpugar/releaes-fluxcd-demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

release-fluxcd-demo

This repository demonstrates GitOps using FluxCD with multiple clusters (staging/production) and different deployment methods:

Repository Structure

├── apps
│   ├── base
│   │   ├── grafana
│   │   ├── podinfo
│   │   ├── prometheus
│   │   └── redis
│   ├── production
│   └── staging
├── infrastructure
│   ├── configs
│   └── controllers
└── clusters
    ├── production
    └── staging

Prerequisites

  1. A Kubernetes cluster v1.28 or newer
  2. GitHub account and personal access token
  3. Flux CLI installed:
    brew install fluxcd/tap/flux
    # or
    curl -s https://fluxcd.io/install.sh | sudo bash
  4. Kubernetes kind installed if using multi cluster setup:
    brew install kind

Applications

1. Podinfo (Kustomize)

  • Simple web application
  • Deployed using Kustomize
  • Different configurations for staging/production

2. Redis (Helm)

  • In-memory data store
  • Deployed using Helm
  • Configured with different persistence settings per environment

3. Grafana (OCI)

  • Monitoring dashboard
  • Deployed using OCI artifacts
  • Different datasource configurations per environment

4. Prometheus (Helm Chart)

  • Monitoring and alerting toolkit
  • Deployed using Helm Chart from prometheus-community

Single cluster setup:

Environment variables:

export GITHUB_TOKEN=<your-token>
export GITHUB_USER=<your-username>
export GITHUB_REPO=release-fluxcd-demo

Bootstrap Cluster:

For STAGING:

# Bootstrap staging
flux bootstrap github \
    --owner=${GITHUB_USER} \
    --repository=${GITHUB_REPO} \
    --branch=main \
    --personal \
    --path=clusters/staging

For PRODUCTION:

# Bootstrap production
flux bootstrap github \
    --owner=${GITHUB_USER} \
    --repository=${GITHUB_REPO} \
    --branch=main \
    --personal \
    --path=clusters/production

Multi cluster setup:

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

Bootstrap Staging Cluster:

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

Bootstrap Production Cluster:

flux bootstrap github \
    --context=production \
    --owner=${GITHUB_USER} \
    --repository=${GITHUB_REPO} \
    --branch=main \
    --personal \
    --path=clusters/production \

Directory Structure Details

Apps Base Configuration

  • apps/base/podinfo: Kustomize manifests for podinfo
  • apps/base/redis: Helm release configuration for Redis
  • apps/base/grafana: OCI image configuration for Grafana
  • apps/base/prometheus: Helm Chart configuration for Prometheus

Environment-Specific Configurations

  • apps/staging: Staging-specific configurations
  • apps/production: Production-specific configurations

Infrastructure

  • infrastructure/controllers: Common controllers (ingress-nginx, cert-manager)
  • infrastructure/configs: Shared configurations

Monitoring Deployments

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published