Created
November 1, 2019 22:00
-
-
Save alexey-igrychev/629f6cf183e53f15ae40db675e810a6d to your computer and use it in GitHub Desktop.
This file contains 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 | |
namespacePrefix=${1:-test-} | |
deltaTS=${2:-$((60 * 60 * 24))} | |
namespaces=$(kubectl get namespace -o json | jq -r "[.items[] | {name: .metadata.name, startTime: .metadata.creationTimestamp | fromdate } | select(.startTime < (now | . - $deltaTS))]" | jq -r ".[].name" | grep $namespacePrefix) | |
for namespace in $namespaces; do | |
kubectl delete ns $namespace | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment