<p>I have created a simple hello world service in my kubernetes cluster. I am not using any cloud provider and have created it in a simple Ubuntu 16.04 server from scratch.
I am able to access the service inside the cluster but now when I want to expose it to the internet, it does not work. </p>

<p>Here is the yml file - deployment.yml</p>

<p><a href="https://i.stack.imgur.com/OKx8c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OKx8c.png" alt="enter image description here"></a></p>

<p>And this is the result of the command - kubectl get all:</p>

<p><a href="https://i.stack.imgur.com/Hlhpn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hlhpn.png" alt="enter image description here"></a></p>

<p>Now when I am trying to access the external IP with the port in my browser, i.e., <strong>172.31.8.110:8080</strong>, it does not work.</p>

<p><strong>NOTE:</strong> I also tried the NodePort Service Type, but then it does not provide any external IP to me. The state remains pending under the "External IP" tab when I do "kubectl get services".</p>

<p>How to resolve this??</p>

Mudit
<p>I believe you might have a mix of networking problems tied together. 
First of all, <code>172.31.8.110</code> belongs to a <a href="https://en.wikipedia.org/wiki/Private_network" rel="nofollow noreferrer">private network</a>, and it is not routable via Internet. So make sure that the location you are trying to browse from can reach the destination (i.e. same private network).</p>

<p>As a quick test you can make an ssh connection to your master node and then check if you can open the page:
<code>curl 172.31.8.110:8080</code></p>

<p>In order to expose it to Internet, you need a to use a public IP for your master node, not internal one. Then update your Service <code>externalIPs</code> accordingly.</p>

<p>Also make sure that your firewall allows network connections from public Internet to <code>8080</code> on master node.</p>

<p>In any case I suggest that you use this configuration for testing purposes only, as it is generally bad idea to use master node for service exposure, because this applies extra networking load on the master and widens security surface. Use something like an Ingress controller (like <a href="https://github.com/kubernetes/ingress-nginx" rel="nofollow noreferrer">Nginx</a> or other) + <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Ingress resource</a> instead.</p>
