Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

338
Views
"bash" not found when running xargs in kubernetes

I am trying to use/understand xargs for printing various details for some pods I have running in kubernetes across different namespaces. E.g. this command gives:

$ kubectl get pods -A | grep Error | awk '{print $2 " -n=" $1}'
my-pod-kf8xch6y-qc6ms-k6ww2 -n=my-ns
my-pod-kf8xlg64-g0ss7-mdv1x -n=my-ns
my-pod-kldslg64-polf7-msdw3 -n=another-ns

which is correct/expected.

When I add xargs to the above command I get:

$ kubectl get pods -A | grep Error | awk '{print $2 " -n=" $1}' | xargs kubectl $1 get pod $0 -oyaml | grep phase
Error from server (NotFound): pods "bash" not found
phase: Failed
phase: Failed

Which is actually the expected output but I don't understand

Error from server (NotFound): pods "bash" not found

why is bash passed to xargs?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

We suggest to avoid xargs complications and combine maximum into single awk script.

kubectl get pods -A | awk '/Error/{system("kubectl get pod "$2" -n="$1" -oyaml")}'|grep phase

Or get even more detailed results:

kubectl get pods -A | awk '/Error/{system("kubectl get pod "$2" -n="$1" -oyaml")}'|grep -E  "(^  name|^  phase)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!