<p>I have some projects in OC, and the names of the pods are generated in base of a chain and a commit. So, I want create an instruction in AzureDevOps to delete all the pods by an incomplete name the name with an specific characters, but finishing with others.</p>
<p>Example:</p>
<pre><code>root@oc-jump-pod:/# oc get po
NAME                           READY     STATUS    RESTARTS   AGE
podA-74rt7                     1/1       Running   0          20h
podB-6744849c59                1/1       Running   0          20h
podB-6746378213                1/1       Running   0          20h
</code></pre>
<p>I need use something like:</p>
<pre><code>oc delete po podB*
Error from server (NotFound): pods &quot;podB*&quot; not found
</code></pre>
<p>How can I filter the deletion with a couple of characters and not the complete name of the pod?</p>
<p>DeployConfig added:</p>
<pre><code>root@oc-jump-pod-pre:/# oc describe deploy NAME
Name:                   NAME
Namespace:              NAME-pre
CreationTimestamp:      Mon, 25 May 2020 07:01:14 +0000
Labels:                 app.kubernetes.io/instance=NAME
                        app.kubernetes.io/managed-by=Helm
                        app.kubernetes.io/name=NAME
                        app.kubernetes.io/version=latest
                        helm.sh/chart=NAME-1.0.0
Annotations:            deployment.kubernetes.io/revision=3
                        meta.helm.sh/release-name=NAME
                        meta.helm.sh/release-namespace=sda-NAME-pre
Selector:               app.kubernetes.io/instance=NAME,app.kubernetes.io/name=NAME
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:           app.kubernetes.io/instance=NAME
                    app.kubernetes.io/name=NAME
  Service Account:  default
  Containers:
   NAME:
    Image:  registry/sda-NAME-dev/test-NAME-java:0.0.2
    Port:   8080/TCP
    Limits:
      cpu:     150m
      memory:  1444Mi
    Requests:
      cpu:     100m
      memory:  1Gi
    Environment:
      APP_NAME:                     NAME
      JAVA_OPTS_EXT:                ....
      SPRING_CLOUD_CONFIG_PROFILE:  pre
      TZ:                           Europe/Madrid
      WILY_MOM_PORT:                5001
      spring_application_name:      NAME_pre
      spring_cloud_config_uri:      https://config.d.cluster.local
    Mounts:
      /etc/jks from jks (ro)
      /etc/secret-vol from secretvol (ro)
      /etc/truststore from jssecacerts (ro)
  Volumes:
....
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Progressing    True    NewReplicaSetAvailable
  Available      True    MinimumReplicasAvailable
OldReplicaSets:  NAME-6744849c59 (1/1 replicas created)
NewReplicaSet:   &lt;none&gt;
Events:          &lt;none&gt;
</code></pre>

RCat
<p>For regex based approach following commands will delete all the pods starting with &quot;podB&quot;</p>
<pre><code>oc get pods | awk '/^podB/{system(&quot;oc delete pod &quot; $1)}'
</code></pre>
<p>Anyway i would recommend using the method provided by Dashrath Mundkar.
For openshift you do not need to provide any namespace if you just want to access resource in your current project so you can just remove the &quot;-n namespace&quot; from the commands like</p>
<pre><code>oc get pod -l labelname=value
</code></pre>
<pre><code>oc delete pod -l labelname=value
</code></pre>
<p>Just make sure the labels you provided are unique to pods you want to delete</p>
