Forum Topic

Thanks for your participation and contribution.


Back to Kubernetes

JQ Tips

Post a reply
285 views
i90runner
i90runner

JQ Tips

https://medium.com/geekculture/my-jq-cheatsheet-34054df5b650

kubectl get pods -ojson | jq '.items[] | {ns:.metadata.namespace, name:.metadata.name,image:.spec.containers[].image} | @csv'
i90runner
i90runner

Containers with previous status had Error State

kubectl get pods -o json --all-namespaces|  jq -c '.items[] | select( .status.containerStatuses[].lastState.terminated.reason == "Error" )'| jq .
i90runner
i90runner
i90runner

JQ Filter

jq '.[] | select(.location=="Stockholm")'

[
{
  "location": "dsagdsfs",
  "name": "Walt"
},
{
  "location": "Stockholm",
  "name": "Donald"
}
]

az ad user list|jq '.[]|{"mail":.mail ,userPrincipalName: .userPrincipalName} |select(.mail=="[email protected]")'
{
  "mail": "[email protected]",
  "userPrincipalName": "[email protected]"
}

Last updated

1-4 of 4

Reply to this discussion

You cannot edit posts or make replies: You should be logged in before you can post.