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 tableTable
The default format. Columns are styled with colors.
bash
kubeadapt get clusters --no-colorExample output:
plaintext
ID NAME PROVIDER REGION NODES STATUS
c1a2b3c4... 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.
bash
kubeadapt get clusters -o jsonExample output:
json
1{
2 "clusters": [
3 {
4 "id": "c1a2b3c4-d5e6-7890-abcd-ef1234567890",
5 "name": "production",
6 "provider": "aws",
7 "region": "eu-west-1",
8 "node_count": 12,
9 "status": "active"
10 },
11 {
12 "id": "cls-def456",
13 "name": "non-production",
14 "provider": "aws",
15 "region": "us-east-1",
16 "node_count": 4,
17 "status": "active"
18 }
19 ]
20}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 yamlExample output:
yaml
1clusters:
2 - id: c1a2b3c4-d5e6-7890-abcd-ef1234567890
3 name: production
4 provider: aws
5 region: eu-west-1
6 node_count: 12
7 status: active
8 - id: cls-def456
9 name: non-production
10 provider: aws
11 region: us-east-1
12 node_count: 4
13 status: activejq recipes
Common patterns for extracting cost data from JSON output:
bash
1# Top 5 workloads by monthly cost
2kubeadapt get workloads -o json | jq '[.workloads[] | {name: .workload_name, namespace, cost: .monthly_cost}] | sort_by(-.cost)[:5]'
3
4# Total monthly savings from pending recommendations
5kubeadapt get recommendations --status pending -o json | jq '.total_potential_savings_monthly'
6
7# Teams spending more than $1,000/month
8kubeadapt get 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