<p>I've had great difficulties routing traffic to k8s API and services.</p>

<p>First I've created a cluster(k8s.buycheese.com) with KOPS in private
topology, within a VPC, so that, master and nodes are only accessible from a bastion using SSH.</p>

<p>I own a domain in namecheap (buycheese.com) and I've created a hosted zone(k8s.buycheese.com) in route53.
After KOPS has installed the cluster, it added a couple of record sets to the hosted zone like <code>api.k8s.buycheese.com</code>.</p>

<p>I've added the hosted zone's namespaces to my domain in namecheap, so that I can access the Kubernetes cluster(kubectl). That works correctly!</p>

<p>Next, I've installed an ingress nginx controller. Then I've created 2 ingresses:</p>

<ul>
<li>One to expose the Kubernetes dashboard</li>
<li>Another one to expose a nodeJS application</li>
</ul>

<p>I then tested my nodeJS Application using the ingress nginx ELB's URL and I can confirm that works! So I know that my pods are running correctly and the ELB works fine!</p>

<p>But obviously, I want my applications to be accessed through the domain I own...</p>

<p>So basically:</p>

<p>I need a new subdomain <code>dashboard.buycheese.com</code> to get to the Kubernetes dashboard.</p>

<p>And I need <code>buycheese.com</code> and <code>www.buycheese.com</code> domains to redirect to my nodeJS app.</p>

<p>Well, to do that, I've created a new hosted zone named buycheese.com in route53, and added 4 new namespaces to my domain buycheese.com in namecheap.</p>

<p>Then I've created 2 aliases(A) within that same hosted zone:</p>

<p><code>dashboard.buycheese.com</code> with Alias Target: ingress nginx's ELB
<code>www.buycheese.com</code> with Alias Target: ingress nginx's ELB</p>

<p>Then within my 2 ingress files</p>

<pre><code># Dashboard
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
  name: kubernetes-dashboard-oidc
  namespace: kube-system
spec:
  rules:
  - host: dashboard.buycheese.com
    http:
      paths:
      - path: /
        backend:
          serviceName: kubernetes-dashboard-oidc
          servicePort: 80


# NodeJS App
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
  name: app
  namespace:default
spec:
  rules:
  - host: buycheese.com
    http:
      paths:
      - path: /
        backend:
          serviceName: app-service
          servicePort: 3000
</code></pre>

<p>To sum up I have 2 hosted zones</p>

<p>1) <code>k8s.buycheese.com</code>
2) <code>buycheese.com</code></p>

<p>2 Alias within hosted zone buycheese.com:</p>

<p>1) <code>www.buycheese.com</code>
2) <code>dashboard.buycheese.com</code></p>

<p>2 Ingresses to expose the dashboard and my app</p>

<p>That configuration does not work at all! The below URLs are not reachable!</p>

<ul>
<li><code>dashboard.buycheese.com</code></li>
<li><code>www.buycheese.com</code></li>
<li><code>buycheese.com</code></li>
</ul>

<p>Only the ELB's URL works!</p>

<p>So first I would like to know whether my set up is correct(obviously no, but why ?)</p>

<p>What's the right way to make all of those URLs exposing my services and applications?</p>

<p>Thanks for your help!</p>

<p>The only thing that I think may be happening here is that <code>Alias Target:</code> is not forwarding to the ELB.</p>

<p>You can try using <a href="https://documentation.unbounce.com/hc/en-us/articles/203687394-Setting-Up-Your-CNAME-with-NameCheap" rel="nofollow noreferrer">CNAME records instead</a>. You can always test using <code>dig</code> from the command line:</p>

<pre><code>$ dig buycheese.com
$ dig www.buycheese.com
$ dig dashboard.buycheese.com
</code></pre>
