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.
kubeadapt get clusters -o json
kubeadapt get clusters -o yaml
kubeadapt get clusters # defaults to tableTable
The default format. Columns are styled with colors using lipgloss.
Use --no-color to strip all ANSI color codes when piping output to a file or another tool.
kubeadapt get clusters --no-colorExample output:
ID NAME PROVIDER REGION NODES STATUS
cls-abc123 production aws eu-west-1 12 active
cls-def456 non-production aws us-east-1 4 activeJSON
Pass -o json to get machine-readable output. This works well with jq for filtering and transforming results.
kubeadapt get clusters -o jsonExample output:
{
"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"
}
]
}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.
kubeadapt get clusters -o yamlExample output:
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: activejq recipes
Common patterns for extracting cost data from JSON output:
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}]'Related
- Examples: real-world usage with jq and pipes
- Command Reference: all available commands