cfg/bin/kube-dump-namespace
Knut Ahlers 4e91ed6c22
Improve k8s ressource listing / dumping
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-06-13 16:26:00 +02:00

37 lines
644 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
source ~/bin/script_framework.sh
namespace="${1:-}"
[[ -n $namespace ]] || fatal "Missing namespace."
step "Collecting available api-resources..."
api_rss=($(
kubectl api-resources --verbs=list --namespaced -o name |
grep -v "events.events.k8s.io" |
grep -v "events" |
sort | uniq
))
for rss in "${api_rss[@]}"; do
step "Fetching resources in api-resource ${rss}..."
names=($(
kubectl -n "${namespace}" \
get --ignore-not-found "${rss}" \
-o name
))
for name in "${names[@]}"; do
echo -e "---\n"
kubectl -n "${namespace}" \
get -o yaml "${name}"
echo
done
done
echo -e "..."