From 98a20fb1234dee4d58ededc36ecfa5149cf9221d Mon Sep 17 00:00:00 2001 From: Adam Robertson Date: Wed, 14 Apr 2021 12:41:44 -0700 Subject: [PATCH 1/2] Update cheatsheet.md Adding a common command I use to ensure common or namespace wide ENV variables are properly set, i.e. by a ConfigMap --- content/en/docs/reference/kubectl/cheatsheet.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/en/docs/reference/kubectl/cheatsheet.md b/content/en/docs/reference/kubectl/cheatsheet.md index f5a971d3bd..2418e82155 100644 --- a/content/en/docs/reference/kubectl/cheatsheet.md +++ b/content/en/docs/reference/kubectl/cheatsheet.md @@ -216,6 +216,10 @@ 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(".")' + +# Produce ENV for all pods +# Make sure to set your default namespace or this will run on system pods +for pod in $(kubectl get po --output=jsonpath={.items..metadata.name}); do echo $pod && kubectl exec -it $pod env; done ``` ## Updating resources From 21bf5f96bcc5d5cf15c0157024bd9a69c8958b9b Mon Sep 17 00:00:00 2001 From: Adam Robertson Date: Thu, 15 Apr 2021 11:28:07 -0700 Subject: [PATCH 2/2] Update cheatsheet.md Adding comments to ensure default namespace, container and that the command is supported. Add note to show you can substitute `env` for any supported command. --- 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 2418e82155..c32ba4f809 100644 --- a/content/en/docs/reference/kubectl/cheatsheet.md +++ b/content/en/docs/reference/kubectl/cheatsheet.md @@ -217,8 +217,8 @@ 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(".")' -# Produce ENV for all pods -# Make sure to set your default namespace or this will run on system pods +# 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` for pod in $(kubectl get po --output=jsonpath={.items..metadata.name}); do echo $pod && kubectl exec -it $pod env; done ```