Skip to content
GreenKube

CLI Reference

import { Aside } from ‘@astrojs/starlight/components’;

GreenKube provides a powerful command-line interface built with Typer and Rich for beautiful terminal output.

The CLI is available as the greenkube command after installation. It provides several subcommands:

Terminal window
greenkube --help
CommandDescription
greenkube startStart the monitoring service + API server + background scheduler
greenkube reportGenerate on-demand reports
greenkube recommendGet optimization recommendations
greenkube demoLaunch a demo with realistic sample data
greenkube versionShow version information
OptionDescription
--no-colorDisable Rich formatting (useful for CI/CD logs)
--versionPrint version and exit
--helpShow help

You can also set NO_COLOR=1 in your environment to disable Rich output globally.

Starts the combined monitoring service: FastAPI server, web dashboard, and background metrics collection scheduler — all in a single process.

Terminal window
greenkube start [OPTIONS]
OptionDescriptionDefault
--portListen port8000
--no-browserDon’t auto-open the browserfalse

Example:

Terminal window
# Start server on default port 8000
greenkube start
# Start on a custom port without opening browser
greenkube start --port 9000 --no-browser

This is the default entrypoint used by the Docker image and Helm chart.

Generate reports for any time period with flexible grouping and filtering options.

Terminal window
greenkube report [OPTIONS]
OptionDescriptionExample
--lastRelative window--last 7d, --last 3m, --last ytd
--startStart date (ISO 8601)--start 2024-01-01
--endEnd date (ISO 8601)--end 2024-12-31
--yearsFull calendar year (repeatable)--years 2024 --years 2023
OptionDescription
--hourlyGroup results by hour
--dailyGroup results by day
--weeklyGroup results by week
--monthlyGroup results by month
--yearlyGroup results by year
--group-by-namespaceReturn one row per namespace instead of per pod
OptionDescriptionExample
--namespace / -nFilter by namespace-n production
--podFilter by pod name--pod "api-*"
--nodeFilter by node name--node "worker-1"
OptionDescriptionDefault
--formatOutput format: table, csv, jsontable
--output / -oWrite output to filestdout
OptionDescription
--fail-on-co2 NExit code 1 if total CO₂e (grams) exceeds N
--fail-on-cost NExit code 1 if total cost (USD) exceeds N
Terminal window
# Daily report for the last 24 hours (terminal table)
greenkube report --last 24h --daily
# Monthly report for a specific namespace, saved to CSV
greenkube report --last 30d --monthly -n production --format csv -o report.csv
# Full calendar year 2024 for CSRD reporting
greenkube report --years 2024 --monthly --format json -o 2024-annual.json
# Custom date range with namespace grouping
greenkube report --start 2024-01-01 --end 2024-06-30 \
--monthly --group-by-namespace --format csv
# CI/CD policy gate
greenkube report --last 24h --fail-on-co2 50000 --fail-on-cost 1000

Each row in the report includes:

ColumnUnitDescription
PodPod name
NamespaceKubernetes namespace
EnergyJoulesEstimated energy consumption
CO₂egramsGHG Scope 2 (operational)
Embodied CO₂egramsGHG Scope 3 (hardware manufacturing)
Total CO₂egramsScope 2 + Scope 3
Cost$Allocated cost from OpenCost
CPU UsagemillicoresAverage CPU utilization
Memory UsagebytesAverage memory usage
Network RxbytesTotal bytes received
Network TxbytesTotal bytes transmitted
Disk ReadbytesTotal disk read
Disk WritebytesTotal disk write
RestartscountContainer restart count
DurationsecondsTime period covered

Analyze recent metrics and generate optimization recommendations.

Terminal window
greenkube recommend [OPTIONS]
OptionDescriptionDefault
--namespace / -nFilter by namespaceAll namespaces
--lastAnalysis window24h
--liveRun live collection instead of reading from databasefalse
--fail-on-recommendationsExit code 1 if any recommendations are foundfalse

Examples:

Terminal window
# Get all recommendations (reads from database)
greenkube recommend
# Recommendations for a specific namespace
greenkube recommend -n production
# Longer lookback window
greenkube recommend --last 7d
# CI/CD gate: fail the pipeline if optimizations exist
greenkube recommend --fail-on-recommendations

Each recommendation includes:

  • Type — zombie, rightsizing (CPU/memory), autoscaling, carbon-aware, idle namespace, off-peak scaling, overprovisioned node, underutilized node
  • Priority — high, medium, low
  • Scope — pod, workload, namespace, or node
  • Details — Current usage vs. recommended
  • Annual savings — Projected CO₂e and cost savings extrapolated to 1 year

Launch a standalone demo instance with realistic sample data — no live cluster metrics required.

Terminal window
greenkube demo [OPTIONS]
OptionDescriptionDefault
--daysNumber of days of sample data to generate30
--portPort for the demo API/dashboard server9000
--no-browserDon’t auto-open the browserfalse

What it does:

  • Creates a temporary SQLite database with realistic Kubernetes metrics
  • Simulates the fictional GreenOptic company with 22 pods across 5 namespaces
  • Generates 30 days of carbon emissions, costs, resource usage, and optimization recommendations
  • Includes a pre-populated savings ledger with applied demo recommendations
  • Starts the API server and dashboard on the specified port

Examples:

Terminal window
# Quick demo (30 days of data, opens browser)
greenkube demo
# Demo with 60 days of data, no browser
greenkube demo --days 60 --no-browser
# Deploy as a standalone Kubernetes pod
kubectl run greenkube-demo \
--image=greenkube/greenkube:latest \
--restart=Never \
--command -- greenkube demo --no-browser --port 9000

Display version information.

Terminal window
greenkube version