kubernetes / kubernetes/kubectl
[request] add -o csv for easy exporting of resources to spreadsheets.
- Dominant language
- Go
- Stars
- 3.3k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
**What would you like to be added**:
I would like to be able to use the output flag to specify csv format when listing resources. For example:
`kubectl get pods -o csv` would output the current pods in a CSV format.
An example of proper CSV format could be
```
NAME ,READY ,STATUS ,RESTARTS ,AGE
Inky ,1/1 ,Running ,3 ,1d10h
Blinky ,1/1 ,Running ,132 ,2d11h
Pinky ,1/1 ,Running ,2 ,3d12h
Clyde ,1/1 ,Running ,0 ,196d13h
```
Which in monospace would not only look like properly formatted CSV, but it would also be properly formatted CSV.
This flag would be valid on any resource that is 'get'-able.
**Why is this needed**:
Not only is this an easy add, as it would be very useful in automation and reporting. Personally, I would be able to perform cluster analysis much faster with this, using something akin to
`kubectl get pods -o csv > myreport.csv`
where I could then paste in formulas in excel and crunch numbers with my own parser.
Thanks for the consideration!
Contributor guide
Research direction
Start at the kubectl get output handling described in the request and trace how the output flag supports resources that can be listed. Define how CSV columns and values should be produced for pods and other get-able resources, then verify that `kubectl get pods -o csv` creates valid CSV suitable for `myreport.csv`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100