Created
February 18, 2025 04:03
-
-
Save fenar/10fe20a66a2369c806b3940708ac07ac to your computer and use it in GitHub Desktop.
CleanUp-Zombie-ReplicaSets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Get all ReplicaSets in all namespaces where no pods are ready (status 0/0) | |
| replicasets=$(oc get rs --all-namespaces --no-headers | awk '$3 == "0" && $4 == "0" {print $1, $2}') | |
| # Loop through the list of ReplicaSets and delete them | |
| echo "$replicasets" | while read namespace rsname | |
| do | |
| echo "Deleting ReplicaSet $rsname in namespace $namespace" | |
| oc delete rs $rsname -n $namespace | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment