diff options
author | Luke Shumaker <lukeshu@datawire.io> | 2020-07-27 14:07:29 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@datawire.io> | 2020-07-27 14:07:29 -0600 |
commit | ff29f3a9a1be30c4cc1ea376a072ae93e3c72cb9 (patch) | |
tree | 0d8391528f5615a1a67bb75d67aa1ba9b044701b /.local/bin | |
parent | 1a332553c19193deac598aa6a1fe9f086d525ee1 (diff) |
kubectl-get-all
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/kubectl-get-all | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/.local/bin/kubectl-get-all b/.local/bin/kubectl-get-all new file mode 100755 index 0000000..f7d1692 --- /dev/null +++ b/.local/bin/kubectl-get-all @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +if [[ $# -eq 0 ]]; then + kubectl api-resources --namespaced=true -o name | xargs printf '%s true\n' + kubectl api-resources --namespaced=false -o name | xargs printf '%s false\n' +else + printf '%s %s\n' "$@" +fi | while read -r type namespaced; do + if [[ $type != *.* ]]; then + type="${type}." + fi + if [[ $namespaced == true ]]; then + kubectl get --all-namespaces "$type" 2>/dev/null | + sed 1d | awk -vtype="$type" '{print type "/" $2, "--namespace=" $1}' + else + kubectl get "$type" 2>/dev/null | + sed 1d | awk -vtype="$type" '{print type "/" $1}' + fi +done |