1

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
  • 2,214
  • 1
  • 24
  • 37
  • OK so the port is the node port that now makes sense. The endpoints are for the pods, which I only have one of. So perhaps this is the minikube single nodes ip address along with the node port, that could make sense, and dns can only be used internally via pods? – sacha barber Feb 26 '18 at 22:18
  • Think that could be it, reading more here https://stackoverflow.com/questions/44112150/external-ip-for-kubernetes-shows-nodes-in-minikube – sacha barber Feb 26 '18 at 22:24
  • Still be good to get answer on how dns work if anyone can comment – sacha barber Feb 26 '18 at 22:24

1 Answers1

2

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
  • 642
  • 3
  • 11
  • Thanks I figured dns may be internal – sacha barber Feb 27 '18 at 17:22
  • does the dns lookup I provide look correct though, I can ssh onto box to check it right? – sacha barber Feb 27 '18 at 17:29
  • Yes, from inside the cluster it should be fine. Although, I am not sure if sshing into node and then using the dns name will work because the network used might be the host network and not the kubernetes SDN. You should try it out and confirm. Having said that, the dns lookup should DEFINITELY work from inside the pods (unless they are also configured to use hostNetwork). – tselvan Feb 28 '18 at 08:18
  • Ok I have tried this and get some weird nslookup error, I will raise this as new question here – sacha barber Feb 28 '18 at 08:59