Kubectl: [request] add -o csv for easy exporting of resources to spreadsheets.

Created on 17 Dec 2020  路  7Comments  路  Source: kubernetes/kubectl

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!

kinfeature lifecyclrotten prioritbacklog triagaccepted

Most helpful comment

Until this is an official feature of kubectl you can use something like this

kubectl get pods | tr -s '[:blank:]' ','

All 7 comments

/triage accepted
/priority backlog

I was a little surprised this was missing. We can add as alpha functionality per @pwittrock.

Until this is an official feature of kubectl you can use something like this

kubectl get pods | tr -s '[:blank:]' ','

/assign

I have filed https://github.com/kubernetes/kubernetes/pull/97562 to implement this feature.

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten

Was this page helpful?
0 / 5 - 0 ratings