<p>i have a handful of dockerized microservices, each is listening for http requests on a certain port, and i have these deployments formalized as kubernetes yaml files</p>

<p>however, i can't figure out a working strategy to expose my deployments on the interwebs (in terms of kubernetes services)</p>

<p>each deployment has multiple replicas, and so i assume each deployment should have a matching load balancer service to expose it to the outside</p>

<p>now i can't figure out a strategy to sanely expose these microservices to the internet... here's what i'm thinking:</p>

<ol>
<li><p><strong>the whole cluster is exposed on a domain name, and services are subdomains</strong>  </p>

<ul>
<li>say the cluster is available at <code>k8s.mydomain.com</code></li>
<li>each loadbalancer service (which exposes a corresponding microservice) should be accessible by a subdomain

<ul>
<li><code>auth-server.k8s.mydomain.com</code></li>
<li><code>profile-server.k8s.mydomain.com</code></li>
<li><code>questions-board.k8s.mydomain.com</code></li>
<li>so requests to each subdomain would be load balanced to the replicas of the matching deployment</li>
</ul></li>
<li>so how do i actually achieve this setup? is this desirable?

<ul>
<li>can i expose each load balancer as a subdomain? is this done automatically?</li>
<li>or do i need an ingress controller?</li>
<li>am i barking up the wrong tree?</li>
<li>i'm looking for general advice on how to expose a single app which is a mosaic of microservices</li>
</ul></li>
</ul></li>
<li><p><strong>each service is exposed on the same ip/domain, but each gets its own port</strong></p>

<ul>
<li>perhaps the whole cluster is accessible at <code>k8s.mydomain.com</code> again</li>
<li>can i map each port to a different load balancer?

<ul>
<li><code>k8s.mydomain.com:8000</code> maps to <code>auth-server-loadbalancer</code></li>
<li><code>k8s.mydomain.com:8001</code> maps to <code>profile-server-loadbalancer</code></li>
</ul></li>
<li>is this possible? it seems less robust and less desirable than strategy 1 above</li>
</ul></li>
<li><p><strong>each service is exposed on its own ip/domain?</strong></p>

<ul>
<li>perhaps each service specifies a static ip, and my domain has A records pointing each subdomain at each of these ip's in a manual way?</li>
<li>how do i know which static ip's to use? in production? in local dev?</li>
</ul></li>
</ol>

<p>maybe i'm conceptualizing this wrong? can a whole kubernetes cluster map to one ip/domain?</p>

<p>what's the simplest way to expose a bunch of microservies in kubernetes? on the other hand, what's the most robust/ideal way to expose microservices in production? do i need a different strategy for local development in minikube? (i was just going to edit <code>/etc/hosts</code> a lot)</p>

<p>thanks for any advice, cheers</p>

ChaseMoskal
<p>The first method is typically the format that everyone follows ie each microservice gets its own subdomain. You can achieve the same using Kubernetes ingress (for example Nginx Ingress <a href="https://kubernetes.github.io/ingress-nginx/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/</a>)</p>

<p>They need not be in the same domain also ie you can have both <code>*.example.com</code> and <code>*.example2.com</code></p>

<p>The second method doesn't scale up as you would have a limited number of available ports and running on non-standard ports comes with its own issues. </p>
