Skip to content

albertoig/homelab

Repository files navigation

🏠 Homelab

A personal homelab setup using Kubernetes (K3s), Helmfile, and GitOps practices for automated infrastructure management.


πŸ“‹ Overview

This repository manages a personal homelab running on Kubernetes (K3s), using Helmfile to deploy services and Ansible to provision bare-metal nodes. Secrets are encrypted with SOPS, and ArgoCD handles GitOps delivery.

This project is the cornerstone of a homelab β€” it provides the base infrastructure (cluster, networking, monitoring, identity). If you want to deploy your own applications (a portfolio site, a blog, custom services, etc.), those should live in a separate repository and be deployed on top of this foundation. This keeps the infrastructure clean and your application deployments independent.


πŸ—οΈ Architecture

The homelab follows a layered architecture:

  1. Infrastructure Layer: K3s cluster provisioned with Ansible
  2. Platform Layer: Core services (MetalLB, Traefik, cert-manager) for networking and certificates
  3. Application Layer: Applications deployed via Helmfile (ArgoCD, Authentik, Grafana, etc.)
  4. Observability Layer: Monitoring (Prometheus), Logging (Loki), Tracing (Tempo), and Profiling (Pyroscope)

Services Deployed

Service Purpose Namespace
prometheus-operator-crds Prometheus Operator CRDs monitoring-system
cert-manager SSL/TLS certificate management cert-manager-system
cert-manager-config Certificate configuration cert-manager-system
external-dns DNS management with Cloudflare cert-manager-system
authentik-blueprints Declarative provider/app/user provisioning auth-system
longhorn Distributed block storage longhorn-system
metallb Load balancer for bare metal lb-system
metallb-config MetalLB IP Address Pool and L2 Advertisement lb-system
prometheus-stack Monitoring and alerting monitoring-system
grafana Metrics visualization monitoring-system
loki Log aggregation monitoring-system
alloy OpenTelemetry collector (logs, traces, profiling) monitoring-system
tempo Distributed tracing monitoring-system
pyroscope Continuous profiling monitoring-system
traefik Reverse proxy and ingress ingress-system
authentik Identity provider auth-system
argocd GitOps continuous delivery gitops-system
authentik-ingress Authentik ingress configuration auth-system

πŸ› οΈ Tech Stack

Tool Purpose
K3s Lightweight Kubernetes distribution
Ansible Cluster provisioning and configuration
Helmfile Helm releases management
Helm Kubernetes package manager
ArgoCD GitOps continuous delivery
SOPS Secrets encryption
Prometheus Monitoring and alerting
Grafana Metrics visualization
Loki Log aggregation
Tempo Distributed tracing
Pyroscope Continuous profiling
Grafana Alloy OpenTelemetry collector for logs, traces, and eBPF profiling
Longhorn Cloud-native distributed block storage
MetalLB Load balancer for bare metal Kubernetes
Traefik Cloud-native reverse proxy
cert-manager X.509 certificate management
external-dns Synchronize exposed services with DNS providers
Authentik Identity provider
Cloudflare DNS and CDN provider
pre-commit Git hooks for code quality
ansible-lint Ansible playbook linting

πŸ“ Project Structure

homelab/
β”œβ”€β”€ charts/                    # Custom Helm charts
β”‚   β”œβ”€β”€ cert-manager-config/   # Certificate configuration
β”‚   β”œβ”€β”€ external-ingress/      # Ingress definitions
β”‚   └── metallb-config/        # MetalLB configuration
β”œβ”€β”€ docs/                      # Documentation
β”œβ”€β”€ helmfile/                  # Helmfile configuration
β”‚   β”œβ”€β”€ common/                # Common values and templates
β”‚   β”‚   β”œβ”€β”€ values/            # Service values files
β”‚   β”‚   └── common.yaml.gotmpl # Main releases definition
β”‚   β”œβ”€β”€ environments/          # Environment-specific configs
β”‚   β”‚   β”œβ”€β”€ dev/               # Development environment
β”‚   β”‚   β”‚   β”œβ”€β”€ secrets/       # Per-chart encrypted secrets
β”‚   β”‚   β”‚   └── values/        # Per-chart value overrides
β”‚   β”‚   └── prod/              # Production environment
β”‚   β”‚       β”œβ”€β”€ secrets/       # Per-chart encrypted secrets
β”‚   β”‚       └── values/        # Per-chart value overrides
β”‚   β”œβ”€β”€ secret-templates/      # Secret templates with descriptions
β”‚   └── locks/                 # Helmfile lock files
β”œβ”€β”€ metal/                     # Bare metal provisioning
β”‚   └── k3s/                   # K3s cluster setup with Ansible
β”œβ”€β”€ scripts/                   # Utility scripts
β”œβ”€β”€ helmfile.yaml.gotmpl       # Main Helmfile entry point
β”œβ”€β”€ ROADMAP.md                 # Project roadmap
└── README.md                  # This file

πŸš€ Getting Started

Fork this repository to store your own configs and secrets. See docs/FORKING.md for setup.

See docs/INSTALL.md for the full setup guide, including prerequisites, helm plugins, credentials, and step-by-step deployment.

# Quick start
./scripts/check-requirements.sh      # verify tools
cp helmfile/config.template.yaml helmfile/environments/<env>/config.yaml  # configure
./scripts/init-secrets.sh <env>       # set up secrets
cd metal/k3s && ./run.sh             # provision cluster
./scripts/install-helmfiles.sh <env> # deploy services

πŸ”§ Configuration

See docs/CONFIG.md for all available settings and docs/SECRETS.md for secrets management.


πŸ“Š Monitoring

The homelab includes a comprehensive monitoring stack:

  • Prometheus: Metrics collection and alerting
  • Grafana: Visualization and dashboards
  • Loki: Log aggregation
  • Tempo: Distributed tracing
  • Pyroscope: Continuous profiling
  • Grafana Alloy: OpenTelemetry collector for logs, traces, and eBPF profiling

Accessing Grafana

Grafana is exposed via MetalLB LoadBalancer. Access it using the external IP assigned by MetalLB.

Pre-configured Dashboards

  • Kubernetes Cluster
  • Node Exporter
  • Kubernetes Pods
  • MetalLB
  • Longhorn
  • CoreDNS
  • External DNS
  • Authentik
  • ArgoCD Operations
  • ArgoCD Application
  • ArgoCD Notifications

πŸ“š Documentation

  • Roadmap β€” upcoming features and progress
  • Testing β€” pre-commit hooks and ansible-lint
  • Configuration β€” config system reference and all available settings
  • Installation β€” step-by-step setup guide
  • Forking β€” how to fork and maintain your own configs and secrets
  • Architecture Decisions β€” ADRs documenting significant infrastructure changes
  • Scripts β€” automation script documentation and usage
  • Secrets β€” full secrets reference with criticality levels

🀝 Contributing

See CONTRIBUTING.md. Every PR with a meaningful change must include an ADR.


πŸ“ License

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


πŸ™ Acknowledgments


⚠️ AI Training Notice

This project does not authorize the use of its code, documentation, or any associated materials for training artificial intelligence (AI) or machine learning (ML) models. Any use of this repository's content for AI/ML training purposes is strictly prohibited without explicit written permission from the project owner.

About

A personal homelab setup using Kubernetes (K3s), Helmfile, and GitOps practices for automated infrastructure management.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors