Trying to expand a for loop variable in this does not succeed - I am trying to use the $i variable in the jsonpath for loop below:
for i in {0..9}; do
echo $i
kubectl exec -i -t "$(kubectl get pod -l "app=mdm-shard" -o jsonpath='{.items[{$i}].metadata.name}')" -- cat /proc/net/udp
done
I get:
0
error: error parsing jsonpath {.items[{$i}].metadata.name}, invalid array index {$i}
error: pod name must be specified
I tried a lot of combinations but can't find the one that is going to expand $i inside the query.
My bash version:
GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)