A few weeks back I did a blog post summing together some information on how to setup Minikube with local access on an OSX machine. In my ever tinkering with Linux on the desktop, I am now just about switched over, but found I couldn't hit local IP's for k8s services for a new operator I'm developing on Minikube like I could on OSX.

This guide will setup your machine with Minikube and I tested it out on Fedora 25. Please let me know if it works out for you and would like to expand to other distro's as well!

Set it up

Route all service IP traffic to Minikube:

sudo ip route delete 10/24 > /dev/null 2>&1 #Cleanup  
sudo ip route add 10.0.0.0/24 via $(minikube ip) #Create Route  

Enable dnsmasq for lookups by editing the file /etc/NetworkManager/NetworkManager.conf and under the [main] section, add the following:

dns=dnsmasq  

Add a file named svc.cluster.local to /etc/NetworkManager/dnsmasq.d with the following contents:

server=/svc.cluster.local/10.0.0.10  
local=/svc.cluster.local/  

Edit the file /etc/nssswitch.conf, find the path hosts: and change it to look like this:

hosts:      files dns myhostname mdns4_minimal  

At this point I had to reboot my system to have everything take.

Test it out!

Start minikube & do all steps above first!

Create a deployment + service:

$ kubectl run nginx --image=nginx     
$ kubectl expose deployment nginx --port=80

Find the ip of the service:

$ nslookup nginx.default.svc.cluster.local                                                                                    
Server:        127.0.0.1  
Address:    127.0.0.1#53

Name:    nginx.default.svc.cluster.local  
Address: 10.0.0.105  

Curl that ip to verify ip connectivity:

$ curl http://10.0.0.105                                                                                                      
<!DOCTYPE html>  
<html>  
<head>  
<title>Welcome to nginx!</title>  
<style>  
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>  
</head>  
<body>  
<h1>Welcome to nginx!</h1>  
<p>If you see this page, the nginx web server is successfully installed and  
working. Further configuration is required.</p>

<p>For online documentation and support please refer to  
<a href="http://nginx.org/">nginx.org</a>.<br/>  
Commercial support is available at  
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>  
</body>  
</html>  

Curl via dns:

$ curl http://nginx.default.svc.cluster.local                                                                                                      
<!DOCTYPE html>  
<html>  
<head>  
<title>Welcome to nginx!</title>  
<style>  
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>  
</head>  
<body>  
<h1>Welcome to nginx!</h1>  
<p>If you see this page, the nginx web server is successfully installed and  
working. Further configuration is required.</p>

<p>For online documentation and support please refer to  
<a href="http://nginx.org/">nginx.org</a>.<br/>  
Commercial support is available at  
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>  
</body>  
</html>