diff options
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 |