I'd like to use kubectl with only jsonpath to obtain the current cluster address. I've tried the following, and many permutations of it, but this doesn't seem to work.
kubectl config view -o jsonpath='{.clusters[?($.current-context)].cluster.server}'
Is this possible using only jsonpath?
You can use the --minify
flag:
--minify=false: Remove all information not used by current-context from the output
And then filter the server
field from the current context output:
kubectl config view --minify -o jsonpath='{.clusters[].cluster.server}'