Home > Enterprise >  Kubectl get JSON extracting
Kubectl get JSON extracting

Time:10-06

I'm looking to pull out json information from a yaml file in kubernetes to specifically get the version of the image I'm using. Any help would be awesome.

command I'm using right now is

kubectl get statefulset -n namespace -o=jsonpath='{$.spec.template.spec.initcontainers[:1].image}'

CodePudding user response:

Did you try using item?

-o jsonpath='{.items[*].spec.template.spec.initcontainers[:1].image}'

CodePudding user response:

This was the solution kubectl get statefulset -n namespace -o=jsonpath='{$.spec.template.spec.containers[*].image}'

this also worked kubectl get statefulset -n namespace -o=jsonpath='{$.spec.template.spec.containers[:1].image}'

  • Related