CLI

CLI Output Formats

Format kubeadapt output as table, JSON, or YAML. Includes examples for piping to jq, disabling colors, and integrating with scripts.

Every command accepts an -o (or --output) flag that controls how Kubernetes cost data is printed. The default is table.

bash
kubeadapt get clusters -o json kubeadapt get clusters -o yaml kubeadapt get clusters # defaults to table

Table

The default format. Columns are styled with colors using lipgloss.

Tip

Use --no-color to strip all ANSI color codes when piping output to a file or another tool.

bash
kubeadapt get clusters --no-color

Example output:

text
ID NAME PROVIDER REGION NODES STATUS cls-abc123 production aws eu-west-1 12 active cls-def456 non-production aws us-east-1 4 active

JSON

Pass -o json to get machine-readable output. This works well with jq for filtering and transforming results.

bash
kubeadapt get clusters -o json

Example output:

json
{ "clusters": [ { "id": "cls-abc123", "name": "production", "provider": "aws", "region": "eu-west-1", "node_count": 12, "status": "active" }, { "id": "cls-def456", "name": "non-production", "provider": "aws", "region": "us-east-1", "node_count": 4, "status": "active" } ] }
Tip

Pipe to jq to extract specific fields:

kubeadapt get clusters -o json | jq '.clusters[0].name'

YAML

Pass -o yaml for YAML output. Useful when you want to feed results into other tools that consume YAML.

bash
kubeadapt get clusters -o yaml

Example output:

yaml
clusters: - id: cls-abc123 name: production provider: aws region: eu-west-1 node_count: 12 status: active - id: cls-def456 name: non-production provider: aws region: us-east-1 node_count: 4 status: active

jq recipes

Common patterns for extracting cost data from JSON output:

bash
kubeadapt get workloads -o json | jq '[.workloads[] | {name: .workload_name, namespace, cost: .monthly_cost}] | sort_by(-.cost)[:5]' # Total monthly savings from pending recommendations kubeadapt get recommendations --status pending -o json | jq '.total_potential_savings_monthly' # Teams spending more than $1,000/month kubeadapt get costs teams -o json | jq '[.teams[] | select(.monthly_cost > 1000) | {team, monthly_cost}]'