<p>I created a debian VM in GCP and installed kubectl and minikube. I deployed one image in the kubectl. I exposed the service using the command <code>kubectl expose deployment hw --type=NodePort --port=80</code>. It exposed in port 31343. But it is not accessible using the external ip of the VM. I added firewall rule to traffic to the port. But still it is not working. How can I access the site using the external ip of the VM.</p>

<p><em>I know, I can use the GKE. But I need to try the kubernetes installation and configuration. That's why I following these steps.</em></p>

NOBLE M.O.
<p>I found a solution by using nginx proxy. May be using kubeadm as mentioned in the previous answer was the standard method. But I didn't get enough reference in the web.
We can use the GCP vm external ip to connect to the nginx server and it will redirect the request to the minikube. Also return the response back.</p>

<ol>
<li>Install nginx in the linux vm using <code>sudo apt install nginx</code></li>
<li>Create a nginx config file <code>sudo vim /etc/nginx/conf.d/upstream.conf</code></li>
<li><p>Add following lines to the file. Replace  and .</p>

<pre><code>upstream app_server_32108 {
    server &lt;minikube ip&gt;:&lt;port&gt;;
}    
server {
    listen 80;
    location /proxy {
       proxy_pass http://app_server_32108/;
    }
}
</code></pre></li>
<li><p><code>sudo nginx -t</code></p></li>
<li><p>Restart nginx server using <code>sudo systemctl reload nginx</code></p></li>
<li><p>Now the content hosted in minikube can access using <code>http://&lt;vm ip&gt;/proxy</code></p></li>
</ol>

<p>If it is not accessible edit nginx config file <code>sudo vim /etc/nginx/nginx.conf</code> and add comment to the line <code>include /etc/nginx/sites-enabled/*;</code> by adding # as prefix.</p>

<blockquote>
  <p><code>#include /etc/nginx/sites-enabled/*;</code></p>
</blockquote>

<p>Restart nginx and try again. (Follow steps 4, 5 and 6).</p>
