I have a total of 2030 pvc's and I want to delete 2000 pvc's form them and keep the 30.
Those 30 pvc's are latest and only less that 2 days old.. so that is why I do not want to delete them. The other all 2000 pvc are more than 2 days old.
I want to create a script that runs automatically to delete the pvc's which are more than 2 days old.
some example of my pvcs:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
data-14353-postgresql-0 Bound pvc-1a6 8Gi RWO gp2 2d15h
data-14354-postgresql-0 Bound pvc-2d6 8Gi RWO gp2 16d
data-14358-postgresql-0 Bound pvc-9dc 8Gi RWO gp2 127m
data-14367-postgresql-0 Bound pvc-2eb 8Gi RWO gp2 65h
data-14370-postgresql-0 Bound pvc-90d 8Gi RWO gp2 56d
now as u can see I have a mixed AGE label.
They can be deleted using:
kubectl delete pvc
but this will delete all.. and I do not want to delete all!
- what command or -label for age I can add to run the command to delete all pvc except those with less than 2 days old.