1

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
  • 111
  • 2

1 Answers1

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.

Additionally, the official docs DNS for Service and Pods and Customizing DNS Service are good resources.

Wesley Rolnick
  • 2,772
  • 12
  • 26