I need to delete deployments that are older than 14 days on clusters. if I run:
oc get deploy --sort-by=.metadata.creationTimestamp | grep wml-os-rt-hybrid | awk '{ print $1 "\t\t" $6;}'
It gives me a list of those deployments and the age of them:
wml-os-rt-hybrid0.1-gz3vczfc 15d
wml-os-rt-hybrid0.1-fj167pbt 8d
wml-os-rt-hybrid0.1-bdzkqi7z 7d
wml-os-rt-hybrid0.1-g4hclw4v 7d
wml-os-rt-hybrid0.1-j6x9tzt6 7d
wml-os-rt-hybrid0.1-qplkkilw 4d
wml-os-rt-hybrid0.1-sadgz9cz 6h
I am brand new to this and can not figure out what I need to add so that it would also delete anything the deployments older then 14d, in this case it would just be the one deployment but in other clusters it would be hundreds. Currently I manually delete it looking at the list and deleting anything older then 14 days by running(using above as example):
oc delete deployment wml-os-rt-hybrid0.1-gz3vczfc
This is the part I am trying to find an answer on how to automate