Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

kubectl jq json pod name

# kubectl does not support regular expressions for JSONpath output
# The following command does not work
kubectl get pods -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}'

# The following command achieves the desired result
kubectl get pods -o json | jq -r '.items[] | select(.metadata.name | test("test-")).spec.containers[].image'
Source by kubernetes.io #
 
PREVIOUS NEXT
Tagged: #kubectl #jq #json #pod
ADD COMMENT
Topic
Name
7+3 =