commit 30253f1e40b762231140edeee0232671061fdb41 Author: Radar231 Date: Wed Dec 8 11:19:07 2021 -0500 initial checkin diff --git a/README.md b/README.md new file mode 100644 index 0000000..74eabc0 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# k8s_cleanup-replicasets repo + +## Introduction + +This is a simple script to clean up orphaned replicaset objects. + diff --git a/clean-k8s-rs.sh b/clean-k8s-rs.sh new file mode 100755 index 0000000..c08879f --- /dev/null +++ b/clean-k8s-rs.sh @@ -0,0 +1,10 @@ +#!/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 +