I'm using a Kubernetes job to run a test; a shell script runs the job and has setup/teardown logic. The job has
restartPolicy: Never
backoffLimit: 2
which means that if the job fails, it'll make a new pod and try again once.
After the job completes, I'd like to dump the logs from all pods in the job. But when I do
kubectl logs job/my-test
I only get logs from one of the pods, prefixed with something like Found 2 pods, using pod/my-test-ntb4w
.
The --all-containers=true
flag doesn't give me logs from all pods.
How can I get logs from all pods in a job, in a shell script?