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 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

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

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.0