summaryrefslogtreecommitdiff
path: root/.local/bin/kubectl-get-all
blob: f7d169267cfa7478ad1da4df878af543e39d0b13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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