How do I grab the desired replica sets of a helm release using jsonpath?

11/1/2018

I have gotten this far:

$kubectl get replicaset --namespace default -l "app=myapp,release=myapp" -o jsonpath="{.items[0].metadata.annotations}"

Which gives me:

map[deployment.kubernetes.io/revision:1 deployment.kubernetes.io/desired-replicas:2 deployment.kubernetes.io/max-replicas:3]

I want to extract '2'

I tried various versions of

$kubectl get replicaset --namespace default -l "app=myapp,release=myapp" -o jsonpath="{.items[0].metadata.annotations.'deployment.kubernetes.io\/desired-replicas'}"

but I am getting a blank response.

Any help is appreciated

-- PeggyScott
jsonpath
kubectl
kubernetes-helm

1 Answer

11/2/2018

Try -o jsonpath="{.items[0].metadata.annotations.deployment\.kubernetes\.io/desired-replicas'}"

I mean just escape the .s with \ if any present in key.

-- Shudipta Sharma
Source: StackOverflow