<p>My purpose is to get all PDB in AKS all namespaces. If a namespace don't have PDB, it should just skip and went to another namespace.
In my local env, bash script can list PDB in all namespaces.
But in Azure pipeline, if a namespace don't contain PDB, the whole bash script just ended and throw error:
No resources found in default namespace.
##[error]Bash exited with code '1'.</p>
<p>My Bash script:</p>
<pre><code>namespace=$(kubectl get namespace|egrep -iv 'name|kube-system'|awk  '{ print $1 }')
echo &quot;${namespace}&quot;
for ns in ${namespace}; 
do 
  poddisruptionbudget=$(kubectl get  pdb -n ${ns}|awk '{ print $1 }'|grep -iv 'name');
  for pdb in ${poddisruptionbudget}; 
  do 
    echo &quot;PDB $pdb in namespace $ns&quot;
    kubectl get -o=yaml pdb $pdb -n $ns &gt;/azp/pdb/$ns-${pdb}.yaml; 
    kubectl delete pdb $pdb -n $ns

  done; 
done
</code></pre>
<p>Azure Pipeline Code:</p>
<pre><code>- task: Bash@3
  displayName: Upgrade AKS cluster
  inputs:
    filePath: '$(System.DefaultWorkingDirectory)/aks-operation/aks_upgrade.sh'
</code></pre>
<p>Try to run a shell script in Azure DevOps pipeline, get all PDB in AKS.
However, some namespace don't container PDB, azure pipeline exited with failure:</p>
<pre><code>No resources found in default namespace.
##[error]Bash exited with code '1'.

</code></pre>

hola
<p>In my whole script:<br />
use to have :</p>
<pre><code>#!/bin/bash
set -e 
</code></pre>
<p>deleted <code>set -e</code>, fixed that, azure pipeline is weird</p>
