k8s_cleanup-replicasets/clean-k8s-rs.sh

11 lines
323 B
Bash
Executable File

#!/bin/bash
nslist="default delfax guacamole home-automation homer k8stv nagios navidrome pihole tiddlywiki"
for i in $nslist
do
echo "Cleaning up orphaned replicasets in namespace ${i}."
kubectl -n $i delete rs $(kubectl -n $i get rs | awk '{if ($2 + $3 + $4 == 0) print $1}' | grep -v 'NAME') 2>/dev/null
done