I need to run a bat file to run kubectl logs
for all containers of a given namespace. This one-liner should do it:
for /f %%i in ('kubectl -n ast get pods -o custom-columns=NAME:.metadata.name --no-headers=true') do kubectl -n ast logs %%i
Here get pods -o custom-columns=NAME:.metadata.name --no-headers=true
lists all generated container names in a column, then for ... do
runs kubectl logs
for each line of this list.
Unfortunately, this gives me an error “custom-columns format specified but no custom columns given”. As far as I can tell, Windows CMD has special meaning for colon “:” inside batch files, and it cannot be screened with “^”, thus the expression after : is ignored.
Is there any way to do this without creating temporary files?