2

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?

cewood
  • 1,011
  • 8
  • 11

1 Answers1

3

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}'
Eduardo Baitello
  • 10,469
  • 7
  • 46
  • 74