Skip to content

About

Flux GitOps scaffold using **Flux v2** for deployment and **GitHub Actions** for CI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Rocket Lab - GitOps with FluxCD Demo

A complete GitOps demonstration using FluxCD v2 and GitHub Actions for continuous deployment of a nginx web application to Kubernetes.

CI-CD

🎯 What This Repository Demonstrates

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

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   GitHub Repo   β”‚    β”‚   Docker Hub    β”‚    β”‚   Kubernetes    β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚   Cluster       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚App Code & β”‚  β”‚    β”‚  β”‚Container  β”‚  β”‚    β”‚  β”‚   Flux    β”‚  β”‚
β”‚  β”‚Manifests  │◄─┼────┼───Images     β”‚  β”‚    β”‚  β”‚Controllersβ”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚       β”‚         β”‚
         β–²                                    β”‚       β–Ό         β”‚
         β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
         └───────────────   GitHub Actions   β”‚β”‚  β”‚Rocket Lab β”‚  β”‚
                        β”‚   CI/CD Pipeline   β”‚β”‚  β”‚   App     β”‚  β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Want to get started immediately? Follow our ⚑ Quick Start Guide for a 10-minute setup!

TL;DR - One Command Deploy

# 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-lab

Then visit http://localhost:8080 to see your GitOps-deployed application! πŸŽ‰

Detailed Setup

For step-by-step instructions with explanations, see the Complete Quick Start Guide.

πŸ“ Repository Structure

β”œβ”€β”€ πŸ“ .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

πŸ”§ Key Features

βœ… GitOps Workflow

  • Declarative Configuration: Everything defined in Git
  • Automated Sync: FluxCD continuously reconciles cluster state
  • Git as Source of Truth: All changes tracked and versioned

βœ… CI/CD Pipeline

  • Automated Builds: GitHub Actions builds and pushes images
  • Security Scanning: Grype scans for vulnerabilities
  • Automated Updates: Image tags updated automatically

βœ… Production Ready

  • 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

βœ… Image Automation

  • Automatic Updates: New image versions deployed automatically
  • Policy-Based: Configurable update policies
  • Git Integration: Changes committed back to repository

πŸŽ›οΈ Configuration

Environment Variables (GitHub Secrets)

DOCKERHUB_USERNAME=<your-dockerhub-username>
DOCKERHUB_TOKEN=<your-dockerhub-access-token>

FluxCD Components

  • 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

πŸ“Š Monitoring and Observability

Check FluxCD Status

# 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

Application Status

# 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

πŸ” Troubleshooting

Common Issues

  1. ImagePullBackOff: Check image name and registry access
  2. Flux Not Syncing: Verify Git repository access and credentials
  3. Pods Not Starting: Check resource limits and node capacity

Debug Commands

# 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-k8s

πŸ“š Documentation

Comprehensive documentation is available in the docs/ directory:

πŸŽ“ Getting Started

πŸ“– Learning Resources

πŸ› οΈ Technical Details

🚨 Troubleshooting

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test with your own cluster
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🎯 Learning Outcomes

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

πŸš€ Next Steps

  1. Explore the Code: Browse through the manifests and configurations
  2. Deploy Locally: Set up your own cluster and deploy the application
  3. Customize: Modify the application and see GitOps in action
  4. Scale Up: Add more environments and applications
  5. Production: Apply these patterns to your real-world projects

🌟 Project Status

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.

🎯 Success Metrics

# 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           Xm

Happy GitOps! πŸŽ‰

Ready to deploy? Start with our ⚑ Quick Start Guide

For questions or support, please open an issue or check the comprehensive documentation.

About

Flux GitOps scaffold using **Flux v2** for deployment and **GitHub Actions** for CI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages