I need to get the metadata->labels->app.kubernetes.io/version value from my pods. But I can't seem to find the jsonpath
that will allow the label key to have the slash and periods.
I have a basic command that is working: kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{end}" -A
. This successfully returns name of each pods.
I have modified this to try to get the version. Here are the permutations that I have attempted (each has failed):
kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.labels.app.kubernetes.io/version}{end}" -A
and
kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.labels.'app.kubernetes.io/version'}{end}" -A
and
kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.labels.`"app.kubernetes.io`/version`"}{end}" -A
How can I get the version using jsonpath
?
I am running in Windows PowerShell if that matters
Escape dots in key name:
.metadata.labels.app\.kubernetes\.io/version
kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.labels.app\.kubernetes\.io/version}{end}" -A