-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·9 lines (9 loc) · 1.79 KB
/
run.sh
1
2
3
4
5
6
7
8
9
#!/bin/sh
kubectl get pods -n webtor | grep Terminating | awk '{print $1}' | xargs kubectl delete po --force --grace-period=0 -n webtor
kubectl get jobs --namespace="webtor" -o json | jq '.items[] | select(.status.succeeded != null or .status.failed !=null) | "kubectl delete job \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 sh -c
kubectl get po --namespace="webtor" -o json | jq '.items[] | select(.status.phase | contains("Pending")) | select(.status.conditions[0].lastTransitionTime | fromdateiso8601? < ((now | floor) - 5)) | select(.metadata.ownerReferences != null) | .metadata.ownerReferences[0] | select(.name | match("(transcoder|seeder)")) | "kubectl delete job \(.name) -n webtor"' | xargs -n 1 sh -c
kubectl get po --namespace="webtor" -o json | jq '.items[] | select(.status.phase | contains("Pending")) | select(.status.conditions[0].lastTransitionTime | fromdateiso8601? < ((now | floor) - 15)) | select(.metadata.ownerReferences == null) | "kubectl delete pod \(.metadata.name) -n webtor"' | xargs -n 1 sh -c
kubectl get po --namespace="webtor" -o json | jq '.items[] | select(.status.phase | contains("Succeeded")) | "kubectl delete po \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 sh -c
kubectl get po --namespace="webtor" -o json | jq '.items[] | select(.status.phase | contains("Failed")) | "kubectl delete po \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 sh -c
kubectl get po --namespace="webtor" -o json | jq '.items[] | select(.status.phase | contains("Running")) | select(.status.conditions[0].lastTransitionTime | fromdateiso8601? < ((now | floor) - 36000)) | select(.metadata.ownerReferences != null) | .metadata.ownerReferences[0] | select(.name | match("(transcoder|seeder)")) | "kubectl delete job \(.name) -n webtor"' | xargs -n 1 sh -c
echo "Finish cleaning!"