From 05a417c303bfb6e48b13a2130243b65ed0e9c10f Mon Sep 17 00:00:00 2001 From: Garron Kramer Date: Wed, 5 Aug 2020 06:52:38 +0300 Subject: [PATCH] Assist those who struggle to find path to relevant keys in Json output. --- content/en/docs/reference/kubectl/cheatsheet.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/content/en/docs/reference/kubectl/cheatsheet.md b/content/en/docs/reference/kubectl/cheatsheet.md index dda75574a9..71f7e6d3f7 100644 --- a/content/en/docs/reference/kubectl/cheatsheet.md +++ b/content/en/docs/reference/kubectl/cheatsheet.md @@ -204,6 +204,13 @@ kubectl get events --sort-by=.metadata.creationTimestamp # Compares the current state of the cluster against the state that the cluster would be in if the manifest was applied. kubectl diff -f ./my-manifest.yaml + +# Produce a period-delimited tree of all keys returned for nodes +# Helpful when locating a key within a complex nested JSON structure +kubectl get nodes -o json | jq -c 'path(..)|[.[]|tostring]|join(".")' + +# Produce a period-delimited tree of all keys returned for pods, etc +kubectl get pods -o json | jq -c 'path(..)|[.[]|tostring]|join(".")' ``` ## Updating Resources