<p>Say, I have two namespaces k8s-app1 and k8s-app2</p>

<p>I can list all pods from specific namespace using the below command</p>

<pre><code>kubectl get pods -n &lt;namespace&gt;
</code></pre>

<p>We need to append namespace to all commands to list objects from the respective namespaces. Is there a way to set specific namespace and list objects without including the namespace explicitly?</p>

P Ekambaram
<p>I like my answers short, to the point and with references to official documentation:</p>
<p><strong>Answer</strong>:</p>
<pre><code>kubectl config set-context --current --namespace=my-namespace
</code></pre>
<p><strong>From</strong>:</p>
<p><a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/" rel="noreferrer">https://kubernetes.io/docs/reference/kubectl/cheatsheet/</a></p>
<pre><code># permanently save the namespace for all subsequent kubectl commands in that context.
kubectl config set-context --current --namespace=ggckad-s2
</code></pre>
