<p>When I am using below it deletes the running POD after matching the pattern from commandline: </p>

<pre><code>kubectl get pods -n bi-dev --no-headers=true | awk '/group-react/{print $1}' | xargs kubectl delete -n bi-dev pod
</code></pre>

<p>However when I am using this command as an alias in .bash_profile it doesn't execute . 
This is how I defined it : </p>

<pre><code> alias kdpgroup="kubectl get pods -n bi-dev --no-headers=true | awk '/group-react/{print $1}'|  kubectl delete -n bi-dev pod"
</code></pre>

<p>when execute this as below I get below error in commandline:</p>

<pre><code>~ $ kdpgroup
error: resource(s) were provided, but no name, label selector, or --all flag specified
</code></pre>

<p>When I define this in .bash_profile I get this : </p>

<pre><code>~ $ . ./.bash_profile
-bash: alias: }| xargs  kubectl delete -n bi-dev pod: not found
~ $
</code></pre>

<p>Am I missing something to delete POD using Pattern Match or with Wilcard  ?</p>

<p>thanks</p>

<blockquote>
  <p>Am I missing something to delete POD using Pattern Match or with Wilcard?</p>
</blockquote>

<p>When using Kubernetes it is more common to use <em>labels</em> and <em>selectors</em>. E.g. if you deployed an application, you usually set a label on the pods e.g. <code>app=my-app</code> and you can then get the pods with e.g. <code>kubectl get pods -l app=my-app</code>.</p>

<p>Using this aproach, it is easier to delete the pods you are interested in, with e.g.</p>

<pre><code>kubectl delete pods -l app=my-app
</code></pre>

<p>or with namespaces</p>

<pre><code>kubectl delete pods -l app=my-app -n default
</code></pre>

<p>See more on <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/" rel="noreferrer">Kubernetes Labels and Selectors</a></p>

<p><strong>Set-based selector</strong> </p>

<blockquote>
  <p>I have some pod's running in the name of "superset-react" and "superset-graphql" and I want to search my wildcard superset and delete both of them in one command</p>
</blockquote>

<p>I suggest that those pods has labels <code>app=something-react</code> and <code>app=something-graphql</code>. If you want to classify those apps, e.g. if your "superset" varies, you could add a label <code>app-type=react</code> and <code>app-type=graphql</code> to all those type of apps.</p>

<p>Then you can delete pods for both app types with this command:</p>

<pre><code>kubectl delete pods -l 'app-type in (react, graphql)'
</code></pre>
