GreenKubeMeasure, understand, and reduce the carbon footprint of your Kubernetes infrastructure. Make your cloud operations both cost-effective and environmentally responsible.
GreenKube is an open-source tool designed to help DevOps, SRE, and FinOps teams get clear carbon visibility and cost control over their Kubernetes infrastructure โ without complex setup or expensive SaaS tools.
๐ Live demo: demo.greenkube.cloud โ explore the dashboard with realistic sample data, no install required.
Cloud computing generates significant carbon emissions, yet most engineering teams have no visibility into the footprint of their Kubernetes workloads. GreenKube addresses this by providing tools to:
/api/v1/docs.DEFAULT_EMBODIED_EMISSIONS_KG, default 350 kg COโe) is used and the metric is flagged as estimated โ ensuring embodied emissions are never silently zeroed out.--last 7d, --last 3m) with flexible grouping (--daily, --monthly, --yearly).kubectl run to explore GreenKube with realistic sample dataโno live cluster metrics needed.readOnlyRootFilesystem, allowPrivilegeEscalation: false, dropped capabilities, and seccompProfile: RuntimeDefault. PostgreSQL uses scram-sha-256 authentication. OWASP security headers (CSP, X-Frame-Options, Referrer-Policy) on every API response. Automated Trivy vulnerability scanning in CI. Secrets can be managed externally via secrets.existingSecret to avoid storing credentials in values.yaml.GreenKube collects metrics from services running in your cluster. It auto-discovers them โ no manual configuration required in most cases.
| Service | Purpose | Required? |
|---|---|---|
| Prometheus | CPU, memory, network, disk metrics | Recommended โ GreenKube works without it but will have no resource metrics |
| OpenCost | Cost allocation data | Optional โ cost fields will be empty without it |
Note: GreenKube works with any Prometheus installation โ basic
prometheus-community/prometheus,kube-prometheus-stack, or a custom setup. The Prometheus Operator is not required for GreenKube to collect data. However, all CO2 data are based on Prometheus, so the installation is really recommended.If auto-discovery fails, set the service URLs manually in
values.yaml(see theconfig.prometheus.urlandconfig.opencost.urlfields).
The recommended way to install GreenKube is via the official Helm chart.
helm repo add greenkube https://GreenKubeCloud.github.io/GreenKube
helm repo update
helm install greenkube greenkube/greenkube \
-n greenkube \
--create-namespace
Explore GreenKube with realistic sample data in under 30 seconds โ no Prometheus or OpenCost required:
With Docker (no Kubernetes needed):
docker run --rm -p 9000:9000 greenkube/greenkube:0.2.9 demo --no-browser --port 9000
# โ Open http://localhost:9000
With kubectl:
kubectl run greenkube-demo \
--image=greenkube/greenkube:0.2.9 \
--restart=Never \
--command -- greenkube demo --no-browser --port 9000
kubectl wait --for=condition=Ready pod/greenkube-demo --timeout=60s
kubectl port-forward pod/greenkube-demo 9000:9000
# โ Open http://localhost:9000
The demo loads 7 days of metrics for 22 pods across 5 namespaces (production, staging, monitoring, data-pipeline, ci-cd) with carbon emissions, costs, and optimization recommendations pre-populated.
kubectl delete pod greenkube-demo # clean up when done (kubectl only)
This deploys GreenKube with the collector, API server, web dashboard, and PostgreSQL โ all in a single command.
| Dashboard | Metrics |
|---|---|
| Nodes | Recommendations |
|---|---|
| Report | Settings |
|---|---|
kubectl port-forward svc/greenkube-api 8000:8000 -n greenkube
# โ Open http://localhost:8000
GreenKube works out of the box, but you have to customize your deployment to have as accurate data as possible. To do so, create a my-values.yaml:
secrets:
# (Optional) Electricity Maps API token โ for real-time grid carbon intensity.
# Get a free token at https://www.electricitymaps.com/
# Without a token, GreenKube uses a default of 500 gCOโe/kWh.
electricityMapsToken: "YOUR_TOKEN_HERE"
# Uncomment to manually set your Prometheus URL
# (If left empty, GreenKube will try to auto-discover it)
# config:
# prometheus:
# url: "http://prometheus-k8s.monitoring.svc.cluster.local:9090"
Then apply it:
helm upgrade greenkube greenkube/greenkube \
-f my-values.yaml \
-n greenkube
Cloud providers automatically expose zone labels on nodes (e.g., topology.kubernetes.io/zone). On-premises clusters do not have these labels, so GreenKube cannot determine the electrical grid zone. You must configure the zone manually:
# 1. Label your nodes with their geographic zone (ISO 3166 country code)
# This tells GreenKube which electrical grid to use for carbon intensity.
# Common zones: FR (France), DE (Germany), US-CAL-CISO (California), GB (UK)
# Full list: https://app.electricitymaps.com/map
kubectl label nodes --all topology.kubernetes.io/zone=FR
# 2. Set the cloud provider to "on-prem" and the default zone in your values
cat <<EOF >> my-values.yaml
config:
cloudProvider: on-prem
defaultZone: FR
EOF
Tip: If your cluster spans multiple locations, label each node individually with the correct zone (e.g.,
FRfor Paris,DEfor Frankfurt).
GreenKube ships with a built-in web dashboard (SvelteKit SPA served by the API). Once deployed, access it via port-forward:
kubectl port-forward svc/greenkube-api 8000:8000 -n greenkube
Then open http://localhost:8000 in your browser.
The dashboard includes:
GreenKube has two distinct Prometheus integrations:
/prometheus/metrics endpoint to expose GreenKube-computed metrics (COโe, cost, energy) in Grafana. This requires either a ServiceMonitor (Prometheus Operator) or a manual scrape_config.If you use the kube-prometheus-stack (Prometheus Operator), enable the ServiceMonitor to let Prometheus scrape GreenKube metrics:
Note: The ServiceMonitor requires the Prometheus Operator CRDs (
monitoring.coreos.com/v1). It is disabled by default to allow installation on clusters without Prometheus Operator.
# In your my-values.yaml
monitoring:
serviceMonitor:
enabled: true # Creates a ServiceMonitor resource (requires Prometheus Operator)
namespace: monitoring # Must match your Prometheus serviceMonitorNamespaceSelector
interval: 30s
networkPolicy:
enabled: true # Allows Prometheus to reach the GreenKube API port
prometheusNamespace: monitoring
Or via --set flags:
helm install greenkube greenkube/greenkube \
-n greenkube --create-namespace \
--set monitoring.serviceMonitor.enabled=true \
--set monitoring.networkPolicy.enabled=true
GreenKube metrics include:
greenkube_pod_co2e_grams โ COโe emissions per pod (cluster, namespace, pod, node, region)greenkube_pod_energy_joules โ Energy consumption per podgreenkube_pod_cost_dollars โ Cost per podgreenkube_pod_cpu_usage_millicores, greenkube_pod_memory_usage_bytes โ Resource usagegreenkube_pod_network_receive_bytes, greenkube_pod_network_transmit_bytes โ Network I/Ogreenkube_sustainability_score โ Composite sustainability score (0โ100, higher is better) per clustergreenkube_sustainability_dimension_score โ Per-dimension score (0โ100) with cluster and dimension labelsgreenkube_carbon_intensity_score โ Energy-weighted average grid carbon intensity (gCOโe/kWh)greenkube_carbon_intensity_zone โ Real-time grid carbon intensity per zonegreenkube_recommendation_total โ Recommendation counts by typegreenkube_node_info โ Node metadata (instance type, zone, capacity)Manual Prometheus config (if not using the Operator):
# Add to your prometheus.yml
scrape_configs:
- job_name: 'greenkube'
scrape_interval: 30s
metrics_path: /prometheus/metrics
static_configs:
- targets: ['greenkube-api.greenkube.svc.cluster.local:8000']
Import the pre-built dashboard from dashboards/greenkube-grafana.json:
dashboards/greenkube-grafana.json (or paste the JSON)The dashboard includes:
cluster and region template variablesThe API is available at /api/v1 and serves both JSON endpoints and the web dashboard.
| Endpoint | Description |
|---|---|
GET /api/v1/health |
Health check and version |
GET /api/v1/version |
Application version |
GET /api/v1/config |
Current configuration |
GET /api/v1/metrics?namespace=&last=24h |
Per-pod metrics |
GET /api/v1/metrics/summary?namespace=&last=24h |
Aggregated summary |
GET /api/v1/metrics/timeseries?granularity=day&last=7d |
Time-series data |
GET /api/v1/namespaces |
List of active namespaces |
GET /api/v1/nodes |
Cluster node inventory |
GET /api/v1/recommendations?namespace= |
Optimization recommendations |
GET /api/v1/report/summary?namespace=&last=24h&aggregate=true&granularity=daily |
Report preview (row count + totals) |
GET /api/v1/report/export?format=csv&last=7d&aggregate=true&granularity=daily |
Download report as CSV or JSON |
Interactive API docs are available at /api/v1/docs (Swagger UI).
# Get a health check
curl http://localhost:8000/api/v1/health
# {"status":"ok","version":"0.2.9"}
# Get metrics for the last 24 hours
curl "http://localhost:8000/api/v1/metrics?last=24h"
# Get metrics summary for a specific namespace
curl "http://localhost:8000/api/v1/metrics/summary?namespace=default&last=7d"
# {"total_co2e_grams":142.5,"total_embodied_co2e_grams":12.3,"total_cost":0.87,...}
# Get hourly timeseries data for the last 7 days
curl "http://localhost:8000/api/v1/metrics/timeseries?granularity=hour&last=7d"
# Get optimization recommendations
curl "http://localhost:8000/api/v1/recommendations?namespace=production"
# Preview a report (row count + totals) before downloading
curl "http://localhost:8000/api/v1/report/summary?last=30d&aggregate=true&granularity=daily"
# {"total_rows":450,"total_co2e_grams":8234.5,"total_cost":12.34,...}
# Download a CSV report for the last 7 days, aggregated daily
curl -O -J "http://localhost:8000/api/v1/report/export?format=csv&last=7d&aggregate=true&granularity=daily"
# Download a raw JSON report for a specific namespace
curl -O -J "http://localhost:8000/api/v1/report/export?format=json&last=30d&namespace=production"
The primary way to interact with GreenKube is by using kubectl exec to run commands inside the running pod.
kubectl get pods -n greenkube
(Look for a pod named something like greenkube-7b5...)
# Replace <pod-name> with the name from the previous step
kubectl exec -it <pod-name> -n greenkube -- bash
greenkube report --daily
See the doc or greenkube report --help to see more options.
greenkube recommend
GreenKube follows a clean, hexagonal architecture with strict separation between core business logic and infrastructure adapters.
Collectors (Input Adapters):
Processing Pipeline (DataProcessor delegates to focused collaborators):
asyncio.gatherCombinedMetric objectsBusiness Logic:
grid_intensity ร PUE as the effective carbon costStorage (Output Adapters):
API & Presentation:
Collection Phase (async/concurrent):
Prometheus โ CPU, memory, network, disk metrics
Kubernetes โ Node metadata, pod resource requests
OpenCost โ Cost allocation data
Processing Phase:
Raw metrics โ Energy estimation (Joules per pod)
Node metadata โ Cloud zone mapping
Historical data โ Node state reconstruction
Calculation Phase:
Energy + Grid intensity + PUE โ COโe emissions
Metrics + Cost data โ Combined metrics
Analysis Phase:
Combined metrics โ Recommendations engine
Time-series data โ Trend analysis
Storage & Presentation:
Combined metrics โ Database (Postgres/SQLite/ES)
Database โ API โ Web Dashboard
API โ CLI reports/exports
asyncio for non-blocking I/O operationsGreenKube's estimation pipeline converts raw Kubernetes metrics into actionable carbon data in four steps:
Embodied emissions are estimated separately via the Boavizta API, which models the manufacturing footprint of cloud instances amortised over their expected lifespan.
For provider-specific coefficients and the full derivation, see docs/power_estimation_methodology.md.
See CHANGELOG.md for a full version history and the GitHub Releases page for published releases.
GreenKube is a community-driven project, and we welcome all contributions! Check out our CONTRIBUTING.md file to learn how to get involved.
# Clone and install
git clone https://github.com/GreenKubeCloud/GreenKube.git
cd GreenKube
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev,test]"
pre-commit install
# Run the tests
pytest
# Run the frontend tests
cd frontend && npm install && npm test
# Start the API locally (uses SQLite by default)
DB_TYPE=sqlite greenkube-api
# Run the frontend
cd frontend && npm install && npm run dev
Report Bugs: Open an Issue with a detailed description.
Suggest Features: Let's discuss them in the GitHub Discussions.
Submit Code: Make a Pull Request!
This project is licensed under the Apache 2.0 License. See the LICENSE file for more details.