<p>I have installed minikube on a server which I can access from the internet.</p>

<p>I have created a kubernetes service which is available:</p>

<pre><code>&gt;kubectl get service myservice
NAME        CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
myservice   10.0.0.246   &lt;nodes&gt;       80:31988/TCP   14h
</code></pre>

<p>The IP address of minikube is:</p>

<pre><code>&gt;minikube ip
192.168.42.135
</code></pre>

<p>I would like the URL <code>http://myservice.myhost.com</code> (i.e. port 80) to map to the service in minikube.</p>

<p>I have nginx running on the host (totally unrelated to kubernetes). I can set up a virtual host, mapping the URL to <code>192.168.42.135:31988</code> (the node port) and it works fine.</p>

<p>I would like to use an ingress. I've added and enabled ingress. But I am unsure of:</p>

<p>a) what the yaml file should contain</p>

<p>b) how incoming traffic on port 80, from the browser, gets redirected to the ingress and minikube.</p>

<p>c) do I still need to use nginx as a reverse proxy?</p>

<p>d) if so, what address is the ingress-nginx running on (so that I can map traffic to it)?</p>

<h1>Setup</h1>

<p>First of all, you need a <a href="https://github.com/kubernetes/ingress-nginx" rel="nofollow noreferrer">nginx ingress controller</a>. </p>

<p>The nginx instance(s) will listen on host 80 and 443 port, and redirect every HTTP request to services which ingress configuration defined, like this.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-service-ingress
annotations:
  # by default the controller redirects (301) HTTP to HTTPS,
  # the following would make it disabled.
  # ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: myservice
          servicePort: 80
</code></pre>

<p>Use <code>https://{host-ip}/</code> to visit myservice, The host should be the one where nginx controller is running at.</p>

<h1>Outside</h1>

<p>Normally you don't need another nginx outside kubernetes cluster.</p>

<p>While Minikube is a little different, It is running kubernetes in a virtual machine instead of host.</p>

<p>We need do some port-forwards like host:80 => minikube:80, Running a reverse proxy (like nginx) in the host is an elegant way.</p>

<p>It can also be done by <a href="https://www.virtualbox.org/manual/ch06.html#natforward" rel="nofollow noreferrer">setting virtual networking port forward in Virtualbox</a>.</p>
