openshiftopenshift-client-tools

Delete all resources via OC CLI with name contain some words


I am looking for a command to delete all resources in openshift, with name contain some words.

I found this but NOT specific to mine. POD delete

I tried below

oc get all -- selector | awk '/^<some word>/{system("oc delete all --selector " $1)}'

it gives below error though. Other thing search should be any part of the name.(not just beginning)

error: you must specify only one resource

Further I noticed below command won't delete configmap

oc delete all --selector app=<app_name> -o name

Solution

  • As mentioned in above comment sections.

    oc get all -oname | grep -i “blaah" | xargs oc delete will delete most of the namespaced resources such as pod,replicaset,deployment,service. However, ConfigMap ,Secret and CRDs won’t be deleted as they do not belong to all Category.