<p>I tried configuring ingress on my kubernetes cluster. I followed the <a href="https://kubernetes.github.io/ingress-nginx/deploy/#generic-deployment" rel="noreferrer">documentation</a> to install ingress controller and ran the following commands</p>

<pre><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/service-nodeport.yaml
</code></pre>

<p>After that default-http-backend and nginx-ingress-controller were running:</p>

<pre><code>ingress-nginx   default-http-backend-846b65fb5f-6kwvp      1/1       Running   0          23h       192.168.2.28   node1
ingress-nginx   nginx-ingress-controller-d658896cd-6m76j   1/1       Running   0          6m        192.168.2.31   node1
</code></pre>

<p>I tried testing ingress and I deployed the following service:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: echoserver-deploy
spec:
  replicas: 2
  selector:
    matchLabels:
      app: echo
  template:
    metadata:
      labels:
        app: echo
    spec:
      containers:
        - name: my-echo
          image: gcr.io/google_containers/echoserver:1.8
---
apiVersion: v1
kind: Service
metadata:
  name: echoserver-svc
spec:
  selector:
    app: echo
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080
</code></pre>

<p>And the following ingress:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: happy-ingress
  annotations:
    INGRESS.kubernetes.io/rewrite-target: /
spec:
  rules:
    - host: happy.k8s.io
      http:
        paths:
          - path: /echoserver
            backend:
              serviceName: echoserver-svc
              servicePort: 8080
</code></pre>

<p>When I ran the command 'kubectl get ing' I received:</p>

<pre><code>NAME            HOSTS          ADDRESS   PORTS     AGE
happy-ingress   happy.k8s.io             80        14m
</code></pre>

<p>I didn't have ADDRESS resolved and I can’t figure out what the problem is because all the pods are running. Can you give me a hint as to what the issue can be?</p>

<p>Thanks</p>

<p>You have to enable <code>ingress addons</code> by following command before creating ingress rules. You can also enable it before executing any other command</p>

<pre><code>$ minikube addons enable ingress
ingress was successfully enabled
</code></pre>

<p>Wait until the pods are up and running. You can check by executing following command and wait for the similar output</p>

<pre><code>kubectl get pods -n kube-system | grep nginx-ingress-controller

nginx-ingress-controller-5984b97644-jjng2   1/1       Running   2          1h
</code></pre>

<p><a href="https://i.stack.imgur.com/VGaeg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VGaeg.png" alt="enter image description here"></a>
For <code>Deployment</code> you have to specify the <code>containerPort</code> and for <code>Service</code> you have to specify <code>http</code> protocol.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: echoserver-deploy
spec:
  replicas: 2
  selector:
    matchLabels:
      app: my-echo
  template:
    metadata:
      labels:
        app: my-echo
    spec:
      containers:
        - name: my-echo
          image: gcr.io/kubernetes-e2e-test-images/echoserver:2.1
          ports:
          - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: echoserver-svc
spec:
  selector:
    app: my-echo
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
    name: http
</code></pre>

<p>For ingress rule change the port <code>servicePort</code> from 8080 to 80 the default http port.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: happy-ingress
  annotations:
    INGRESS.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: happy.k8s.io
    http:
      paths:
      - path: /echoserver
        backend:
          serviceName: echoserver-svc
          servicePort: 80
</code></pre>

<p>Now apply those files and create your pods, service and ingress rule. Wait few moment, it will take few moments to get ADDRESS for your ingress rule.
<a href="https://i.stack.imgur.com/gNzOe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gNzOe.png" alt="enter image description here"></a>
Now you can visit your service using <code>minikube ip</code> address but not by host name yet. For that you have to add the host and respective IP address in <code>/etc/hosts</code> file. So open <code>/etc/hosts</code> file in your favorite editor and add below line where  is the actual IP of you minikube</p>

<pre><code>&lt;minikube_ip&gt; happy.k8s.io
</code></pre>

<p>Now you access you service using host name. Verify be following command</p>

<pre><code>curl http://happy.k8s.io/echoserver
</code></pre>
