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 continuous monitoring service
greenkube reportGenerate on-demand reports
greenkube recommendGet optimization recommendations
greenkube demoLaunch a demo with realistic sample data
greenkube apiStart the API server
greenkube versionShow version information

Starts the background monitoring service that continuously collects metrics.

Terminal window
greenkube start [OPTIONS]
OptionDescriptionDefault
--with-apiAlso start the API serverfalse
--intervalCollection interval (e.g., 5m, 1h)5m
--analyze-nodesEnable node analysistrue

Example:

Terminal window
# Start collector + API server
greenkube start --with-api
# Start collector only with custom interval
greenkube start --interval 10m

Generate reports for any time period with flexible grouping options.

Terminal window
greenkube report [OPTIONS]
OptionDescriptionExample
--lastReport for the last N time units--last 7d, --last 3m, --last 1y
--dailyShortcut for --last 1d--daily
--startStart date (ISO format)--start 2024-01-01
--endEnd date (ISO format)--end 2024-01-31
OptionDescription
--dailyGroup results by day
--monthlyGroup results by month
--yearlyGroup results by year
OptionDescriptionExample
--namespace / -nFilter by namespace-n default
--podFilter by pod name pattern--pod "api-*"
OptionDescriptionDefault
--formatOutput format: table, csv, jsontable
--output / -oWrite output to filestdout
Terminal window
# Daily report for the last 24 hours (terminal table)
greenkube report --daily
# Weekly report in JSON format
greenkube report --last 7d --format json
# Monthly report for a specific namespace, saved to file
greenkube report --last 30d --monthly -n production -o report.csv --format csv
# Custom date range
greenkube report --start 2024-01-01 --end 2024-01-31 --monthly
# Last 3 months, grouped by month
greenkube report --last 3m --monthly

The report includes the following data per pod/group:

ColumnUnitDescription
PodPod name
NamespaceKubernetes namespace
EnergyJoulesEstimated energy consumption
CO₂egramsCarbon dioxide equivalent emissions
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
--lookbackDays of historical data to analyze7
--formatOutput format: table, jsontable
--liveUse real-time collection instead of databasefalse

Example:

Terminal window
# Get all recommendations
greenkube recommend
# Recommendations for a specific namespace
greenkube recommend -n production
# JSON output for automation
greenkube recommend --format json

Each recommendation includes:

  • Type: zombie, rightsizing, autoscaling, carbon-aware
  • Severity: low, medium, high, critical
  • Resource: Affected pod or namespace
  • Details: Current usage vs. recommended
  • Savings: Estimated cost and CO₂ reduction
  • Action: Suggested kubectl command

Launch a standalone demo instance with realistic sample data — no live cluster metrics required. Perfect for evaluating GreenKube or creating demos for your team.

Terminal window
greenkube demo [OPTIONS]
OptionDescriptionDefault
--daysNumber of days of sample data to generate7
--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
  • Generates data for 22 pods across 5 namespaces (production, staging, monitoring, data-pipeline, ci-cd)
  • Includes carbon emissions, costs, resource usage, and optimization recommendations
  • Starts the API server and dashboard on the specified port

Examples:

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

Start the FastAPI server (and web dashboard) independently.

Terminal window
greenkube api [OPTIONS]
OptionDescriptionDefault
--hostListen address0.0.0.0
--portListen port8000

Display version information.

Terminal window
greenkube version

Output:

GreenKube v0.2.3