<p>I have some endpoint running on a pod inside of my Kubernetes cluster that is secured by basic auth. The normal way of accessing this pod through the API server would be:</p>
<pre><code>https://{{ apiServer }}:{{ apiServerPort }}/api/v1/namespaces/{{ namespaceName }}/pods/{{ podName }}:{{ podPort }}/proxy/somepath
</code></pre>
<p>This works fine for endpoints that are not secured using Basic Auth, but when trying to access the secure endpoints, I get a 403 Forbidden every time because I can not specify two authentication headers and I already need to authenticate myself to the API server itself.
Is it possible to get those Basic Auth credentials forwarded to the pod or am I out of luck using the API server proxy?</p>

W3D3
<p>The working solution that I can think of is to use <code>kubectl port-forward</code>. As a result of that Kubernetes API server will establish a single http connection between your localhost and the resource running on your cluster. This will preserve all your client requests.</p>
<pre><code>kubectl port-forward TYPE/NAME [options] LOCAL_PORT:REMOTE_PORT
</code></pre>
<p>You can send the traffic to specific pod, use random local port or even specify local ip address use for forwarding.</p>
<p>You can read more about port forwarding <a href="https://kubectl.docs.kubernetes.io/pages/container_debugging/port_forward_to_pods.html" rel="nofollow noreferrer">here</a> and check <a href="https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/" rel="nofollow noreferrer">this</a> example in the official kuberentes document.</p>
<p>If you want some alternatives you want to check <a href="https://www.telepresence.io/" rel="nofollow noreferrer">telepresence</a>.</p>
<p>PS. I tried to use a sidecar container with kubectl proxy but that did not work unfortunately.</p>
