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
  • No additional services required
greenkube:
dbType: "sqlite"
sqlitePath: "/data/greenkube.db"
  • Optimized for large-scale metric storage
  • Advanced time-series aggregation queries
  • Integrates with Kibana for additional visualization
  • Ideal for organizations already running an ELK stack
greenkube:
dbType: "elasticsearch"
elasticsearchUrl: "http://elasticsearch:9200"

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 supports data export/import to facilitate migration:

Terminal window
# Export from current backend
greenkube export --format json --output metrics.json
# Import into new backend
greenkube import --input metrics.json