Skip to content
GreenKube

Flexible Storage

GreenKube is storage-agnostic by design. The application core never depends on a specific storage implementation, letting you choose the backend that best fits your use case.

  • Full SQL support with time-series optimized queries
  • Included in the Helm chart as a StatefulSet
  • Persistent storage with configurable PVC
  • Supports connection pooling and replicas
values.yaml
greenkube:
dbType: "postgresql"
postgresql:
enabled: true
storage: "10Gi"
  • Zero infrastructure — single file database
  • Perfect for local development and testing
  • Great for single-node standalone deployments
  • SCD2 node snapshots — Slowly Changing Dimensions Type 2 tracking stores only changed node rows (instance_type, vcpu, memory_gb, region, provider, zone), avoiding write amplification on stable clusters
greenkube:
dbType: "sqlite"
sqlitePath: "/data/greenkube.db"

The storage agnosticism is achieved through the Repository Pattern:

┌──────────────────┐
│ Business Logic │ ← Calls repository.save_metric()
│ (Core) │ Never knows about SQL/NoSQL
└────────┬─────────┘
│ interface
┌────────┴─────────┐
│ Repository │ ← Abstract interface
│ Interface │
└────────┬─────────┘
┌────┼────┐
▼ ▼ ▼
PG SQLite ES ← Concrete implementations

This means:

  • Switching backends requires only a configuration change
  • The business logic is fully tested without any real database
  • New backends can be added without touching the core

Backend instantiation is handled by core/factory.py:

# Simplified example
def create_repository(config: Config) -> MetricRepository:
if config.db_type == "postgresql":
return PostgreSQLRepository(config.db_url)
elif config.db_type == "sqlite":
return SQLiteRepository(config.sqlite_path)
elif config.db_type == "elasticsearch":
return ElasticsearchRepository(config.es_url)

GreenKube uses a configurable multi-tier retention strategy:

TierDefaultEnv Var
Raw metrics (5-min)7 daysMETRICS_RAW_RETENTION_DAYS
Hourly aggregatesInfiniteMETRICS_AGGREGATED_RETENTION_DAYS (-1 = infinite)
Compression threshold24 hMETRICS_COMPRESSION_AGE_HOURS

Raw metrics are automatically compressed to hourly aggregates after the threshold, keeping storage compact without losing historical visibility. Infinite aggregated retention is the default to support multi-year CSRD/ESRS E1 compliance.