How to get the current namespace of current context using kubectl? : <p>I am trying to get the namespace of the currently used Kubernetes context using <code>kubectl</code>.</p>

<p>I know there is a command <code>kubectl config get-contexts</code> but I see that it cannot output in json/yaml. The only script I've come with is this:</p>

<pre class="lang-sh prettyprint-override"><code>kubectl config get-contexts --no-headers | grep '*' | grep -Eo '\S+$'
</code></pre>
