<p>I just created a namespace, have done nothing with it and now deleted it. However, when I list contexts I can still see it there. It seems to have been deleted as I can't delete it again. Why can I still see it listed when I get contexts?</p>

<pre><code>kubectl config get-contexts
CURRENT   NAME       CLUSTER    AUTHINFO   NAMESPACE
*         dev        minikube   minikube   dev
          minikube   minikube   minikube

kubectl delete namespace dev
namespace "dev" deleted

kubectl config get-contexts
CURRENT   NAME       CLUSTER    AUTHINFO   NAMESPACE
*         dev        minikube   minikube   dev
          minikube   minikube   minikube
</code></pre>

<p>I switched contexts just in case but still get the same problem. E.g.</p>

<pre><code>kubectl delete namespace dev
Error from server (NotFound): namespaces "dev" not found

kubectl config get-contexts
CURRENT   NAME       CLUSTER    AUTHINFO   NAMESPACE
          dev        minikube   minikube   dev
*         minikube   minikube   minikube
</code></pre>

<p>Interestingly, I don't see it when I list namespaces. E.g.</p>

<pre><code>kubectl get namespaces
</code></pre>

Snowcrash
<p>A <code>context</code> in <code>kubectl</code>is just a local config that contains details (metadata) about a particular cluster or a namespace. This is the config that is needed for cluster/namespace management using the <code>kubectl</code> client.</p>

<p>So, when you type <code>kubectl config &lt;any_command&gt;</code>, it's just doing a lookup in a file stored locally on you computer.
Run the following to know more about this command and how to control the location of the config file:</p>

<pre><code>kubectl config --help
</code></pre>

<p>Deleting a cluster or a namespace does not delete the associated context. The reason is that the deleting of a cluster or a namespace is an asynchronous operation that runs on the cluster. This operation may take longer than a few seconds to actually finish. Thus, <code>kubectl</code> cannot immediately delete the context from the config file after you issues the delete to the cluster master.</p>

<p>To answer your question, you have to manually delete the context using:</p>

<pre><code>kubectl config delete-context dev
</code></pre>
