<p>The approach I've seen work for this is to use Nginx as the LoadBalancer and defining the Ingress with type NodePort for the different services.  You can see a tutorial that shows the first steps for setting this up <a href="https://medium.com/@awkwardferny/getting-started-with-kubernetes-ingress-nginx-on-minikube-d75e58f52b6c" rel="nofollow noreferrer">here</a>.</p>

<p>Additionally, the official docs <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">DNS for Service and Pods</a> and <a href="https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/" rel="nofollow noreferrer">Customizing DNS Service</a> are good resources.</p>

CC BY-SA 4.0
2019-09-24T14:41:30.477Z
2019-09-24T14:41:30.477Z
Wesley Rolnick
<p>I have a Minikube installation in which I created a simple hello-world deployment like this:</p>

<pre><code>kubectl create deployment hello-node \
    --image=gcr.io/hello-minikube-zero-install/hello-node
</code></pre>

<p>I exposed the deployment via a service in the following way:</p>

<pre><code>kubectl expose deployment hello-node --type=LoadBalancer --port=8080
</code></pre>

<p>Now If I call: <code>http://&lt;local cluster ip&gt;:8080</code> it prints "Hello World!" as expected.</p>

<p><strong>What I want to achieve:</strong></p>

<p>I want to expose different deployments in the same cluster to different sub-domains of the cluster. For instance, deployment <code>hello1</code> to <code>hello1.my-k8-cluster.com</code>, <code>hello2</code> to <code>hello2.my-k8-cluster.com</code>.</p>

<p>I want to test this locally because later I will do the same on a real cluster.</p>

<p><strong>Question:</strong> How to test DNS configurations of services locally? How to define sub-domains in services?</p>

<p><strong>What I tried so far:</strong>
I went through the how-to guides <a href="https://kubernetes.io/docs/tutorials/hello-minikube/#create-a-deployment" rel="nofollow noreferrer">here</a> and <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">the documentation</a> which though didn't bring me a clear picture on how to configure what I want.</p>

<kubernetes><minikube>
Kubernetes expose an app via a DNS name in minicube
Sasha Shpota
# Kubernetes expose an app via a DNS name in minicube

(Asked by: username_0 on 2019-09-24)

I have a Minikube installation in which I created a simple hello-world deployment like this:
kubectl create deployment hello-node \
    --image=gcr.io/hello-minikube-zero-install/hello-node

I exposed the deployment via a service in the following way:
kubectl expose deployment hello-node --type=LoadBalancer --port=8080

Now If I call: http://:8080 it prints "Hello World!" as expected.
What I want to achieve:
I want to expose different deployments in the same cluster to different sub-domains of the cluster. For instance, deployment hello1 to hello1.my-k8-cluster.com, hello2 to hello2.my-k8-cluster.com.
I want to test this locally because later I will do the same on a real cluster.
Question: How to test DNS configurations of services locally? How to define sub-domains in services?
What I tried so far:
I went through the how-to guides here and the documentation which though didn't bring me a clear picture on how to configure what I want.

**Tags:** kubernetes, minikube


---

## 1 answers

### Answer by username_1 on 2019-09-24. Score: 1

The approach I've seen work for this is to use Nginx as the LoadBalancer and defining the Ingress with type NodePort for the different services. You can see a tutorial that shows the first steps for setting this up [here](https://medium.com/@awkwardferny/getting-started-with-kubernetes-ingress-nginx-on-minikube-d75e58f52b6c).

Additionally, the official docs [DNS for Service and Pods](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/) and [Customizing DNS Service](https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/) are good resources.


---

