How to completely purge minikube config or reset IP back to 192.168.99.100

12/20/2018

I want to completely purge Minikube so that I could start over as if I installed it for the first time to avoid some configuration clashes. Mailnly to have initial IP 192.168.99.100, unfortunatelly it increases on next minikube start to 192.168.99.101, etc. I've run to delete Minikube:

minikube delete rm -rf ~/.minikube rm -rf ~/.kube

I'm running minikube version: v0.31.0 on Ubuntu 18.04 with driver VirtualBox 5.2.18

-- Sobik
kubernetes
minikube

5 Answers

7/22/2019

I've recently run into this issue on mpb; tracking down issues with minikube helm and tiller on VirtualBox v6.0.10

Cleanest solution I've found works as expected

#!/bin/sh

function minikube_reset_vbox_dhcp_leases() {
  # # Reset Virtualbox DHCP Lease Info
  echo "Resetting Virtualbox DHCP Lease Info..."
  kill -9 $(ps aux |grep -i "vboxsvc\|vboxnetdhcp" | awk '{print $2}') 2>/dev/null

  if [[ -f ~/Library/VirtualBox/HostInterfaceNetworking-vboxnet0-Dhcpd.leases ]] ; then
    rm  ~/Library/VirtualBox/HostInterfaceNetworking-vboxnet0-Dhcpd.leases
  fi
}

minikube_reset_vbox_dhcp_leases

Credit: issues/951

-- ramene
Source: StackOverflow

7/9/2019

If you use virtualbox as the vm-driver, you can use this Python script on Linux/Mac to reset the ip to 192.168.99.100:

./minikube_reset

#!/usr/bin/env python3

import subprocess as sp
from sys import platform
import os

if __name__ == "__main__":

    print("Resetting Virtualbox DHCP...")

    procs = sp.run("ps aux", shell=True, stdout=sp.PIPE)\
        .stdout.decode("utf8").lower().split('\n')

    pids = [
        p.split()[1] for p in procs if 'vboxsvc' in p or 'vboxnetdhcp' in p
    ]

    for pid in pids:
        sp.run(['kill', '-9', pid])

    cfg_dir = ".config" if platform != 'darwin' else 'Library'
    file = f"~/{cfg_dir}/VirtualBox/HostInterfaceNetworking-vboxnet0-Dhcpd.leases"

    try:
        os.remove(os.path.expanduser(file))
    except OSError as e:
        pass

If you make the script an executable via chmod +x minikube_reset and put it into your path, you can run:

minikube stop    # Stop your running minikube instance.
minikube_reset   # Reset the ip.
minikube start   # Start new minikube instance with 192.168.99.100.

Your minikube instance should always start with 192.168.99.100 after minikube_reset.

-- Rotareti
Source: StackOverflow

4/15/2019

I found this problem on the Mac with VirtualBox as well. I tried removing the Host Network Manager, but it did not work for me. However, I did find another solution.

After issuing minikube delete, I removed the following file:

/Users/{username}/Library/VirtualBox/HostInterfaceNetworking-vboxnet0-Dhcpd.leases

Starting minikube again reset the address to .100.

File contents:

<?xml version="1.0"?>
<Leases version="1.0">
  <Lease mac="08:00:27:66:6a:19" id="01080027666a19" network="0.0.0.0" state="expired">
    <Address value="192.168.99.102"/>
    <Time issued="1555277299" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:08:03:a3" id="010800270803a3" network="0.0.0.0" state="expired">
    <Address value="192.168.99.101"/>
    <Time issued="1555276993" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:32:ed:f8" id="0108002732edf8" network="0.0.0.0" state="expired">
    <Address value="192.168.99.100"/>
    <Time issued="1555276537" expiration="1200"/>
  </Lease>
</Leases>
-- user3137124
Source: StackOverflow

12/21/2018

Minikube is used on different platforms, so it might be helpful to add information related to most popular of them.

Minikube is not responsible for assigning IP address to its VM.

If you are starting minikube on Windows or MacOS new VM is created. That VM gets the first available IP address from the pool of hypervisor DHCP service. In brief, DHCP service reserves this IP for the VM for some period of time, usually from 24 hours to 7 days. If in this period the client doesn't refresh DHCP lease and this IP is not available on the network, the IP is considered free and can be offered to another client.

VirtualBox has only basic settings for its DHCP service, you are not allowed to configure lease time or static ip binding. So, you may try to change ip configuration of minikube VM network interface, after VM is created using minikube ssh. Or you can play with VM MAC address right after creation because DHCP offers IP address based on host MAC address.

HyperV uses existed DHCP on local network for shared networks or manually configured DHCP server for internal networks. If you have access to DHCP administration console you can delete the old minikube VM IP binding before starting a new VM using minikube start.

For Linux you can choose two options, you can use virtualbox hypervisor and create VM like it works on Windows or MAC, so DHCP will work like I've mentioned previously, or you can use -vm-driver=none argument and setup Kubernetes cluster inside host environment without VM. In this case your host machine becomes a Kubernetes master node with the same IP configuration.

-- VAS
Source: StackOverflow

5/3/2019

For Ubuntu 18.0.4 you can try

rm -r /home/username/.config/VirtualBox/HostInterfaceNetworking-vboxnet0-Dhcpd.leases
-- Akhil J
Source: StackOverflow