kubernetes-gitops-blueprint

Kubernetes GitOps Blueprint

CI Release GitHub Pages License: MIT Kubernetes ArgoCD

A production-ready GitOps blueprint for Kubernetes using ArgoCD, Helm, Kustomize, and GitHub Actions. Includes a sample microservices application with CI/CD, monitoring, and multi-environment deployments.

🏗️ Architecture

┌─────────────────┐
│   Developer     │
│   Git Push      │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│  GitHub Actions │
│  CI Pipeline    │
│  - Build        │
│  - Test         │
│  - Scan         │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ Container       │
│ Registry        │
│ (Docker Hub/    │
│  GHCR)          │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│   ArgoCD        │
│   - Sync        │
│   - Monitor     │
│   - Self-Heal   │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│  Kubernetes     │
│  Cluster        │
│  - API Service  │
│  - Worker       │
│  - Redis        │
│  - Monitoring   │
└─────────────────┘

✨ Features

📋 Prerequisites

🚀 Quick Start

1. Bootstrap ArgoCD

First, ensure ArgoCD is installed in your cluster:

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

2. Create ArgoCD Projects

Apply the project definitions:

kubectl apply -f argocd/projects/microservices.yaml
kubectl apply -f argocd/projects/monitoring.yaml

3. Deploy App-of-Apps

Deploy the root application that manages all other applications:

kubectl apply -f argocd/app-of-apps.yaml

ArgoCD will automatically discover and sync all applications defined in the applications/ directory.

4. Monitor Deployment

Watch the ArgoCD applications:

kubectl get applications -n argocd
argocd app list

Access ArgoCD UI:

kubectl port-forward svc/argocd-server -n argocd 8080:443
# Open https://localhost:8080 (admin password from argocd-initial-admin-secret)

📁 Project Structure

kubernetes-gitops-blueprint/
├── README.md                 # This file
├── LICENSE                   # MIT License
├── .gitignore                # Git ignore rules
├── argocd/                   # ArgoCD configuration
│   ├── app-of-apps.yaml     # Root application (app-of-apps pattern)
│   ├── projects/            # ArgoCD project definitions
│   │   ├── microservices.yaml
│   │   └── monitoring.yaml
│   └── applications/        # Individual application manifests
│       ├── api-service.yaml
│       ├── worker-service.yaml
│       ├── redis.yaml
│       └── monitoring-stack.yaml
├── helm-charts/             # Helm charts for services
│   ├── api-service/         # API service chart
│   ├── worker-service/      # Worker service chart
│   └── redis/               # Redis chart
├── kustomize/               # Kustomize configurations
│   ├── base/                # Base configuration
│   └── overlays/            # Environment-specific overlays
│       ├── dev/
│       ├── staging/
│       └── prod/
├── monitoring/              # Monitoring stack configs
│   ├── prometheus/          # Prometheus configuration
│   └── grafana/             # Grafana dashboards and configs
└── .github/
    └── workflows/           # GitHub Actions workflows
        ├── ci.yml           # CI pipeline
        └── release.yml      # Release pipeline

🌍 Environment Management

This blueprint uses Kustomize overlays to manage different environments:

Development

kubectl apply -k kustomize/overlays/dev

Staging

kubectl apply -k kustomize/overlays/staging

Production

kubectl apply -k kustomize/overlays/prod

📊 Monitoring

Prometheus

Prometheus is configured to scrape metrics from all services. Access the Prometheus UI:

kubectl port-forward svc/prometheus-server -n monitoring 9090:80

Grafana

Grafana dashboards are automatically provisioned. Access Grafana:

kubectl port-forward svc/grafana -n monitoring 3000:80
# Default credentials: admin/admin

Pre-configured dashboards:

Alerting

Prometheus alerting rules are defined in monitoring/prometheus/rules/alerts.yaml. Alerts include:

🔧 Configuration

Helm Values

Customize deployments by modifying values in helm-charts/*/values.yaml:

ArgoCD Sync Policy

Applications are configured with automated sync policies:

To disable auto-sync for production, modify the sync policy in the application manifest.

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

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

🙏 Acknowledgments

📚 Additional Resources

Support

If you find this useful, consider buying me a coffee!

Buy Me A Coffee