Skip to content

Commit

Permalink
k8s: horrible xargs hacks to find unused crds
Browse files Browse the repository at this point in the history
Signed-off-by: clux <[email protected]>
  • Loading branch information
clux committed Jul 19, 2024
1 parent 5178822 commit f04b2d0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .k8s-helpers
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ kleftovers() {
| xargs -n 1 kubectl get --show-kind --ignore-not-found
}

# find crds without instances
kcrdunused() {
kubectl get crds -o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | xargs -P16 -I "{}" sh -c '[ "$(kubectl get {} --no-headers -A 2> /dev/null | wc -l)" -eq 0 ] && echo "{}"'
}

# check versions in all contexts
kcver() {
for ctx in $(kubectl config get-contexts -o name | grep -v fqdn); do
Expand Down

0 comments on commit f04b2d0

Please sign in to comment.