1
votes

NOTE: this is I think a bash question, not kubernetes or kubectl

I can run the following:

kubectl get pods -n myspace -w

which will "watch" and provide a stream of lines with e.g. pod name, ready count, status, restarts, and age

similarly I can run

kubectl get pods -n myspace -w -o json

which will provide more fine-grained change info. I note that the end of a json block appears to be an unindented } and an unindented { next begins the following block.

my question is, how could I pipe the above to write individual files based on either a new line, or an unindented {?

If there is a native kubernetes way to do that that does not involve extensions or plugins this would be a viable solution though I would prefer a pure bash command-line solution.