A complete GitOps demonstration using FluxCD v2 and GitHub Actions for continuous deployment of a nginx web application to Kubernetes.
This repository showcases a production-ready GitOps workflow that automatically:
- π Builds and pushes container images via GitHub Actions
- π Scans images for vulnerabilities using Grype
- π¦ Deploys applications to Kubernetes using FluxCD
- π Updates deployments automatically when new images are available
- ποΈ Manages infrastructure declaratively through Git
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β GitHub Repo β β Docker Hub β β Kubernetes β
β β β β β Cluster β
β βββββββββββββ β β βββββββββββββ β β βββββββββββββ β
β βApp Code & β β β βContainer β β β β Flux β β
β βManifests ββββΌβββββΌβββ€Images β β β βControllersβ β
β βββββββββββββ β β βββββββββββββ β β βββββββββββββ β
βββββββββββββββββββ βββββββββββββββββββ β β β
β² β βΌ β
β βββββββββββββββββββββββ βββββββββββββ β
ββββββββββββββββ€ GitHub Actions ββ βRocket Lab β β
β CI/CD Pipeline ββ β App β β
βββββββββββββββββββββββ βββββββββββββ β
βββββββββββββββββββ
Want to get started immediately? Follow our β‘ Quick Start Guide for a 10-minute setup!
# Clone, install Flux, and deploy
git clone https://github.com/eknathdj/devops-gitops-flux.git
cd devops-gitops-flux
curl -s https://fluxcd.io/install.sh | sudo bash
flux install
kubectl apply -f manifests/flux/
kubectl port-forward svc/devops-sample-svc 8080:80 -n rocket-labThen visit http://localhost:8080 to see your GitOps-deployed application! π
For step-by-step instructions with explanations, see the Complete Quick Start Guide.
βββ π .github/workflows/ # GitHub Actions CI/CD pipeline
βββ π charts/myapp/ # Helm chart for the application
βββ π docs/ # Comprehensive documentation
βββ π k8s/ # Kubernetes manifests
β βββ π base/ # Base Kustomize resources
β βββ π overlays/dev/ # Environment-specific overlays
βββ π manifests/flux/ # FluxCD configuration
β βββ π image-automation/ # Image automation setup
βββ π Dockerfile # Container image definition
βββ π index.html # Custom nginx welcome page
βββ π nginx.conf # Nginx configuration
βββ π README.md # This file
- Declarative Configuration: Everything defined in Git
- Automated Sync: FluxCD continuously reconciles cluster state
- Git as Source of Truth: All changes tracked and versioned
- Automated Builds: GitHub Actions builds and pushes images
- Security Scanning: Grype scans for vulnerabilities
- Automated Updates: Image tags updated automatically
- Health Checks: Readiness and liveness probes configured
- Resource Limits: CPU and memory limits set
- Multi-Environment: Kustomize overlays for different environments
- Monitoring: Built-in observability with FluxCD
- Automatic Updates: New image versions deployed automatically
- Policy-Based: Configurable update policies
- Git Integration: Changes committed back to repository
DOCKERHUB_USERNAME=<your-dockerhub-username>
DOCKERHUB_TOKEN=<your-dockerhub-access-token>- GitRepository: Monitors this repository for changes
- Kustomization: Applies Kubernetes manifests
- ImageRepository: Monitors Docker Hub for new images
- ImagePolicy: Defines update policies
- ImageUpdateAutomation: Automatically updates image tags
# Overall health check
flux check
# View all Flux resources
flux get all
# Check specific components
flux get sources git
flux get kustomizations
flux get image repository# Check pods
kubectl get pods -n rocket-lab
# View deployment status
kubectl get deployment devops-sample-app -n rocket-lab
# Check service
kubectl get svc devops-sample-svc -n rocket-lab- ImagePullBackOff: Check image name and registry access
- Flux Not Syncing: Verify Git repository access and credentials
- Pods Not Starting: Check resource limits and node capacity
# View Flux controller logs
kubectl logs -n flux-system deployment/source-controller
kubectl logs -n flux-system deployment/kustomize-controller
# Check events
kubectl get events -n rocket-lab --sort-by='.lastTimestamp'
# Force reconciliation
flux reconcile source git devops-repo
flux reconcile kustomization rocket-lab-k8sComprehensive documentation is available in the docs/ directory:
- β‘ Quick Start Guide - Get running in 10 minutes
- π Documentation Index - Complete documentation overview
- π― FluxCD Complete Guide - Comprehensive FluxCD tutorial from basics to advanced
- π§ Configuration Analysis - Deep dive into Flux configuration best practices
- β Applied Fixes - Summary of all improvements made
- π§ͺ Test Results - Validation and testing documentation
- π ImagePull Issues - Container image troubleshooting
- π Status Updates - Real-time issue resolution logs
- Fork the repository
- Create a feature branch
- Make your changes
- Test with your own cluster
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
By exploring this repository, you'll learn:
- β GitOps Principles: Declarative, versioned, and automated deployments
- β FluxCD Operations: Source management, kustomizations, and image automation
- β Kubernetes Best Practices: Health checks, resource management, and observability
- β CI/CD Integration: Automated builds, testing, and deployments
- β Container Security: Image scanning and vulnerability management
- Explore the Code: Browse through the manifests and configurations
- Deploy Locally: Set up your own cluster and deploy the application
- Customize: Modify the application and see GitOps in action
- Scale Up: Add more environments and applications
- Production: Apply these patterns to your real-world projects
Status: FULLY OPERATIONAL β
- β GitOps workflow implemented and tested
- β Application successfully deployed and running
- β Image automation configured and ready
- β CI/CD pipeline functional
- β Comprehensive documentation complete
See Project Status for detailed metrics and achievements.
# Current deployment status
kubectl get all -n rocket-lab
# Expected output:
# NAME READY STATUS RESTARTS AGE
# pod/devops-sample-app-xxxxxxxxx-xxxxx 1/1 Running 0 Xm
# pod/devops-sample-app-xxxxxxxxx-xxxxx 1/1 Running 0 Xm
#
# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
# service/devops-sample-svc ClusterIP 10.x.x.x <none> 80/TCP Xm
#
# NAME READY UP-TO-DATE AVAILABLE AGE
# deployment.apps/devops-sample-app 2/2 2 2 XmHappy GitOps! π
Ready to deploy? Start with our β‘ Quick Start Guide
For questions or support, please open an issue or check the comprehensive documentation.