<p>I've set up two simple kubernetes services &amp; deployments - frontend &amp; api. The frontend gets data from the api so I'm exposing the api as well so I can hard code the backend ingress URL in the frontend data fetch call (if anyone knows a better way of doing this internally within cluster please let me know).</p>

<p>I'm trying to set up different host names for different services but for some reason only one of the hostnames is working.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-webapp-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: test-webapp-frontend.com
    http:
      paths:
        - path: /
          backend:
            serviceName: test-webapp-frontend-lb
            servicePort: 8002
  - host: test-webapp-api.com
    http:
      paths:
        - path: /get
          backend:
            serviceName: test-webapp-api-lb
            servicePort: 8001
</code></pre>

<p>And this is what I get after I run <code>kubectl get svc</code></p>

<pre><code>NAME                      TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
kubernetes                ClusterIP      10.96.0.1        &lt;none&gt;        443/TCP          2d
test-webapp-api-lb        LoadBalancer   10.107.60.163    &lt;pending&gt;     8001:30886/TCP   1h
test-webapp-frontend-lb   LoadBalancer   10.104.100.108   &lt;pending&gt;     8002:31431/TCP   1h
</code></pre>

<p>I am using minikube on my local to run this cluster. I can access both the frontend and api by running <code>minikube service test-webapp-frontend-lb</code> and <code>minikube service test-webapp-api-lb</code>.</p>

<p>When I go to <code>test-webapp-frontend.com</code>, I can see the frontend page but I can't access <code>test-webapp-api.com</code>. Not even the default not-found error, I just can't access it as if the URL just didn't exist.</p>

<p>The weird thing is, if I do this,</p>

<pre><code>spec:
  rules:
  - host: test-webapp-frontend.com
    http:
      paths:
        - path: /
          backend:
            serviceName: test-webapp-frontend-lb
            servicePort: 8002
  - host: test-another-frontend.com
    http:
      paths:
        - path: /
          backend:
            serviceName: test-webapp-frontend-lb
            servicePort: 8002
</code></pre>

<p>I can still access <code>test-webapp-frontend.com</code> but <code>test-another-frontend.com</code> has the same problem, can't access it at all.</p>

<p>What am I doing wrong??</p>

mkim
<p>Seems like a DNS problem. Those hostname a like 'test-webapp-frontend.com' need to resolve to the IP of the ingress controller to route traffic into the cluster. I don't see an external IP listed in your output for an ingress controller. For minikube you could enable the ingress add-on. DNS is a bit trickier with minikube as you don't have a public IP to resolve to. You can modify you etc/hosts file to resolve the names or use path-based rules instead. </p>

<p>Some useful <a href="https://stackoverflow.com/questions/52345855/ingress-and-ingress-controller-how-to-use-them-with-nodeport-services/52346482#52346482">links</a> on <a href="https://medium.com/@awkwardferny/getting-started-with-kubernetes-ingress-nginx-on-minikube-d75e58f52b6c" rel="nofollow noreferrer">this</a> </p>
