<p>I wanted to execute <code>kubectl exec</code> command and connect to a container, so that I can execute some commands on it.
I have set the proxy with the following command:</p>

<pre><code>kubectl proxy -p=8080 --kubeconfig=/directory_path/remote-kubeconfig &amp;
</code></pre>

<p>proxy started running. I tried executing <code>kubectl exec</code> command:</p>

<pre><code>kubectl exec -it &lt;pod&gt; --namespace=&lt;namespace&gt; -c &lt;container&gt; -- ls -l
</code></pre>

<p>I got the following error:</p>

<pre><code>error: unable to upgrade connection: &lt;h3&gt;Unauthorized&lt;/h3&gt;
</code></pre>

<p>Did I missed anything while executing <code>kubectl exec</code> command ?? Please help.</p>

<p>I got a solution for this problem but not a good one.</p>

<p>I issued <code>--disable-filter</code> along with <code>kubectl proxy</code> command.  After that, I could execute <code>kubectl exec</code> commands successfully.  </p>

<p>But when I use <code>--disable-filter</code>, it is prone to vulnerability. 
A message <code>Request filter disabled, your proxy is vulnerable to XSRF attacks, please be cautious</code> is displayed with <code>--disable-filter</code>.</p>

<p>so, I dont think that this is a good solution.</p>

<p><strong>Please let me know, if any one knows better solution for this problem.</strong></p>
