kubesort
kubesort copied to clipboard
Accept piped data
Here is how I would want to use kubesort. Being able to pipe data into it in addition to using it as a command wrapper could be very useful.
Using bash and sort has some limitations but I think it mostly just works as expected (I didn't test every field)
You can run it without args and it'll default to AGE column
kubectl get po| ./kubesort
NAME READY STATUS RESTARTS AGE
nginx2 1/1 Running 1 29m
nginx 1/1 Running 2 21h
postgres-0 1/1 Running 0 4d4h
counter-7b58954fbf-zszkb 1/1 Running 0 4d4h
or run it with a column to sort.
kubectl get po| ./kubesort restarts
NAME READY STATUS RESTARTS AGE
counter-7b58954fbf-zszkb 1/1 Running 0 4d4h
postgres-0 1/1 Running 0 4d4h
nginx2 1/1 Running 1 29m
nginx 1/1 Running 2 21h
When you pipe data to it it doesn't limit what fields can be sorted but it does require you to use a header row because that's where it bases the sort argument from.
It might be good to handle tests in case the data is malformed or if kubectl spits out help text.