Map service on minikube to host IP

1/7/2019

This is my first time running through the Kubernetes tutorial. I installed Docker, Kubectl and Minikube on a headless Ubuntu server (18.04). I ran Minikube like this -

minikube start --vm-driver=none

I have a local docker image that run a restful service on port 9110. I create a deployment and expose it like this -

kubectl run hello-node --image=dbtemplate --port=9110 --image-pull-policy=Never
kubectl expose deployment hello-node --type=NodePort 

status of my service -

# kubectl get services
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
hello-node   NodePort    10.98.104.45   <none>        9110:32651/TCP   39m
kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP          3h2m

# kubectl describe services hello-node
Name:                     hello-node
Namespace:                default
Labels:                   run=hello-node
Annotations:              <none>
Selector:                 run=hello-node
Type:                     NodePort
IP:                       10.98.104.45
Port:                     <unset>  9110/TCP
TargetPort:               9110/TCP
NodePort:                 <unset>  32651/TCP
Endpoints:                172.17.0.5:9110
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

# minikube ip
192.168.1.216

As you can see, the service is available on the internal IP of 172.17.0.5.

Is there some way for me to get this service mapped to/exposed on the IP of the parent host, which is 192.168.1.216. I would like my restful service at 192.168.1.216:9110.

-- Quest Monger
ip
kubectl
kubernetes
minikube

1 Answer

1/7/2019

I think minikube tunnel might be what you're looking for. https://github.com/kubernetes/minikube/blob/master/docs/networking.md

Services of type LoadBalancer can be exposed via the minikube tunnel command.

-- coderanger
Source: StackOverflow