JSONPath range not working when using kubectl JSONPath range not working when using kubectl kubernetes kubernetes

JSONPath range not working when using kubectl


Your command works for me in kubectl 1.9.2

If it still doesn't work, you can use tr in bash to replace spaces with new lines:

kubectl config view -o=jsonpath="{.contexts[*].name}" | tr " " "\n" 


I figured it out. I had been using @ahmetb's kubectl-aliases script, which works fine with no problem, but one of the suggestions in the README was:

Print the full command before running it: Add this to your .bashrc or .zshrc file:

function kubectl() { echo "+ kubectl $@"; command kubectl $@; }

I had that function declaration in my .bashrc and it was stripping off the quotes for my jsonpath argument. As soon as I commented out that declaration and opened a new shell, the command worked correctly.