<p>I am new to Kubernetes and wanted to understand how I can expose a service running in Kubernetes to the outside world. I have exposed it using a NodePort on the cluster. 
So, for example: A service exposes port 31234 on the host and I can get to the service from another server through <a href="https://kubeserverIP:31234" rel="noreferrer">https://kubeserverIP:31234</a>.</p>

<p>What I want to achieve is serve this service through nginx (on a different server, out of Kube control) via a url,say, <a href="http://service.example.com" rel="noreferrer">http://service.example.com</a>. I have tried deploying nginx with an upstream pointing to the service but that is not working and get a bad gateway error. </p>

<p>Is there something which I am missing here? Or is there a neater way of achieving this.</p>

<p>I have a baremetal installation of Kubernetes cluster and have no access to gce load balancer or other vendor LBs.</p>

<p>Thanks</p>

devops84uk
<p>Thanks for pointing in the right direction. </p>

<p>Essential steps broadly were:</p>

<ol>
<li><p>Create an app and its service definition.</p></li>
<li><p>Create a namespace for ingress.</p></li>
<li>Create a default backend deployment and service for redirecting all requests not defined in Ingress rules. Create these in the ingress space</li>
<li>Create the nginx ingress controller deployment. </li>
<li>Create RBAC rules.</li>
<li>Finally create the ingress rule for the applications with the paths and the ports.</li>
</ol>

<p>Found a very useful guide which explained things in details:
<a href="https://akomljen.com/kubernetes-nginx-ingress-controller/" rel="noreferrer">https://akomljen.com/kubernetes-nginx-ingress-controller/</a></p>
