From f62e3032af41235936553a056b6398b15e5a71c7 Mon Sep 17 00:00:00 2001 From: Meng-Yuan Huang Date: Mon, 14 Feb 2022 10:20:18 +0800 Subject: [PATCH] Simplify commands. Simplify commands to output paths to all elements. Note: the jq filter "path(..)" is simplified to "paths," however, there is a trivial difference: the filter "paths" doesn't output the top path "[]." --- content/en/docs/reference/kubectl/cheatsheet.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/en/docs/reference/kubectl/cheatsheet.md b/content/en/docs/reference/kubectl/cheatsheet.md index 87451a03ac..113f26800d 100644 --- a/content/en/docs/reference/kubectl/cheatsheet.md +++ b/content/en/docs/reference/kubectl/cheatsheet.md @@ -212,10 +212,10 @@ 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(".")' +kubectl get nodes -o json | jq -c 'paths|join(".")' # Produce a period-delimited tree of all keys returned for pods, etc -kubectl get pods -o json | jq -c 'path(..)|[.[]|tostring]|join(".")' +kubectl get pods -o json | jq -c 'paths|join(".")' # Produce ENV for all pods, assuming you have a default container for the pods, default namespace and the `env` command is supported. # Helpful when running any supported command across all pods, not just `env`