<p>I am testing k8s on ubuntu using virtual box.</p>
<p>I have two nodes, one is master, another is worker node.</p>
<p>I deployed a pod containing nginx server container for test.</p>
<p>I can access the webpage deployed by the pod on master node with commands below</p>
<p>kubectl port-forward nginx-server 8080:80</p>
<p>curl localhost:8080</p>
<p>but I want to open this page on my host os(windows10) using chrome web browser
<a href="https://i.stack.imgur.com/KgDnV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KgDnV.png" alt="enter image description here" /></a></p>
<p>This is how I set port-forwading on virtual-box...</p>

ben kwon
<p>simply answer your question, use <code>address</code> args for the kubectl command:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl port-forward --address 0.0.0.0 nginx-server 8080:80
</code></pre>
<p>here is the explanation:</p>
<ol>
<li><code>kubectl port-forward</code> bind to <code>localhost</code> by default</li>
<li>the <code>port forward</code> for your <code>virtual box</code> is bind to <code>10.100.0.104</code></li>
<li><code>0.0.0.0</code> will bind the port to both <code>localhost</code> and <code>10.100.0.104</code></li>
<li>change <code>0.0.0.0</code> to <code>10.100.0.104</code> will also work for <code>10.100.0.104</code> access, but not the <code>localhost</code></li>
</ol>
<p>and also, when exposing a port, you could use a <code>NodePort</code> service: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#nodeport</a></p>
