<p>with the command <code>kubectl get deploy -A -o yaml</code> I can get the all deployments definition, includes the namespaces <code>kube-system</code> and <code>monitoring</code> which are not my target services.</p>
<p>I tried to use the command <code>kubectl get deploy -A |grep -v kube-system |grep -v monitoring</code> and got the target deployments like:</p>
<pre class="lang-bash prettyprint-override"><code>$ kubectl  get deploy -A |grep -v kube-system |grep -v monitoring
NAMESPACE     NAME                                     READY   UP-TO-DATE   AVAILABLE   AGE
default       nginx-deploy                             2/2     2            2           103d
default       test                                     1/1     1            1           48d
mai           mai-1                                    10/10   10           10          85d
mai           mai-w                                    1/1     1            1           20d
mai           test-deploy-1                            1/1     1            1           68d
q-test        nginx-deployment-demo-01                 5/5     5            5           64d
</code></pre>
<p>In fact I need to get the all deployments <code>nginx-deploy,test,mai-1,mai-w,test-deploy-1,nginx-deployment-demo-01</code> as above. So I tried below command:
<code>kubectl  get deploy -A |grep -v kube-system |grep -v monitoring -oyaml</code>, as expected it failed to get the target deployments definition.</p>
<p>Any one could help to fix it?</p>

Marco Mei
<p>This should do the task in you are on bash:</p>
<pre><code>for ns in $(kubectl get ns -o name  --no-headers |grep -v kube-system); do
    kubectl get deployment -n ${ns##*/}&quot;  -o yaml;
done
</code></pre>
<p>In the above snippet, first, the list of namespaces is captured and filtered and then looped.</p>
