skip to Main Content

For example:

command
kgp -o jsonpath='{range .items[]}{range @.spec.containers[]}{@.name}{"t"}{.items[].metadata.name}{"n"}{end}{"n"}{end}’

output

  • nginx
  • istio-proxy
  • sidecar-1

expected output

  • nginx default
  • istio-proxy default
  • sidecar-1 default

2

Answers


  1. I think you want to print the pattern podname namespace. Is that right? Then you have to change .items[].metadata.name to .items[].metadata.namespace.

    Login or Signup to reply.
  2. Try this:

    kubectl get po -o jsonpath='{range .items[*]}{@.spec.containers[*].name}{" "}{@.metadata.namespace}{"n"}{end}'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search