Kubernetes expose an app via a DNS name in minicube

9/24/2019

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://<local cluster ip>: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.

-- Sasha Shpota
kubernetes
minikube

1 Answer

9/24/2019

You cannot define subdomains on Services. Services have the form service-name.namespace.svc.domain.

If you want to manipulate the DNS names, you should look at Ingress.

In order to test DNS configurations, you can use normal DNS testing tools like dig from inside a container. You can use public images like dnsutils or create your own testing images for this purpose.

-- Alassane Ndiaye
Source: StackOverflow