Kubernetes DNS / Endpoint

2/26/2018

So I am fairly new to Kubernetes. I am a Windows user (sorry) and have installed Minikube. I am trying to learn Kubenetes using MiniKube. I have created very simple REST API that should work with port 5000 exposed where there is a simple route /Hello/{somestring}

I have created a POD/Deployment and Service for this successfully in MiniKube like this

minikube.exe start --kubernetes-version="v1.9.0" --vm-driver="hyperv" --memory=1024 --hyperv-virtual-switch="Minikube Switch" --v=7 --alsologtostderr 
kubectl run simple-sswebapi-pod-v1 --replicas=1 --labels="run=sswebapi-pod-v1" --image=sachabarber/sswebapp:v1  --port=5000
kubectl expose deployment simple-sswebapi-pod-v1 --type=NodePort --name=simple-sswebapi-service
kubectl get services simple-sswebapi-service

Which I can then grab the url from and paste into my browser like so

minikube service simple-sswebapi-service --url 

Which gives me this URL

http://192.168.0.29:32246

Which I then try in the browser on my host, all is good my REST API is running as expected

enter image description here

But from what I have read, I believe I should be able to ALSO use a DNS name for the service rather than this url returned above.

In fact I am not sure what this IP address returned as part of the --url command is trying to tell me above. It is not one of the ones listed for the service endpoints for is it for the POD from what I can tell from the Dashboard.

This is the service

enter image description here

This is the POD

enter image description here

Shouldn't there be a DNS name available for the service that I should be able to use instead of this fairly hacky way of grabbing the url from the service I just created. Someone please let me know what this --url even represents. I am lost here

I have checked that the DNS add on is enabled in MiniKube it is, see kube-dns in list below

enter image description here

As I say this is also what I see for the service inside of the MiniKube Dashboard

enter image description here

This confused me even more as I cant seem to tie any of that back to the ONLY IP address that seems to actually work for me, which is the one I grabbed using this line from the service

.\minikube.exe service simple-sswebapi-service --url 

This Ip Address is not shown in the dashboard at all.

I thought the service should be available at DNS name something like:

simple-sswebapi-service.default.svc.cluster.local

Which is the

  • The name of the service
  • The namespace
  • svc to tell its a service

Just for completeness this is me describing the service in command line

enter image description here

What am I missing?

Is my mental mode wrong. I should be able to see this service using a DNS in the host too? Or is the DNS name ONLY available inside the PODS?

-- sacha barber
dns
kubernetes

1 Answer

2/27/2018

kube-dns is internal DNS. You can only use the DNS name for a service from inside the cluster.

Since your service type is Nodeport, you can connect to the service using the IP of the machine (minikube) on that port.

-- tselvan
Source: StackOverflow