kubernetes / minikube

Run Kubernetes locally
https://minikube.sigs.k8s.io/
Apache License 2.0
29.28k stars 4.87k forks source link

Support for predictable IP's across restarts #951

Closed RaeesBhatti closed 4 years ago

RaeesBhatti commented 7 years ago

Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

Minikube version (use minikube version): v0.14.0

Environment:

What happened: Minikube changes IP address when recreated.

What you expected to happen: Minikube should retain the IP address when deleted and created again.

How to reproduce it (as minimally and precisely as possible):

Anything else do we need to know: I have several things configured to Minikube's IP address and have to recreate it occasionally. They all have to be reconfigured each time. It would be convenient to have Minikube not change its IP address after deleting and recreating.

daxgames commented 5 years ago

A bit heavy handed way to guarantee minikube gets 192.168.99.100 everytime with virtualbox.

function minikube_reset_vbox_dhcp_leases() {
  # # Reset Virtualbox DHCP Lease Info
  common_message_print "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
leifcr commented 5 years ago

@daxgames I'm using similar approach, however if you have other vboxes on the same host network, all will ip's will be new for those as well when deleting the dhcp leases file. I haven't found a way to remove single ip's through the vbox management cli.

daxgames commented 5 years ago

@LEIFCR I am aware of that, like I said its heavy handed. I needed something quick.

If you have code that is less aggressive please share, it could save me some time.

tstromberg commented 5 years ago

This issue may be fixed for some users with #3572 - which shipped with minikube v0.34.1.

I can confirm though that the problem still exists for kvm2, however. I'd love to hear if it helps for any other users.

Tressflin commented 5 years ago

I am on MacOS 10.14 (Mojave), minikube v.0.33.1, Virtualbox 6.0.4.

@massenz I am getting the incrementing IP even just with minikube start/stop (no delete).

@dgoldssfo Thank you so much - this is what finally fixed it for me. It seems that it works as long as the Virtualbox app is closed (so I can do stop, delete leases, and start and be at .100 again)

@tstromberg Thanks for the heads up on the new version. Unfortunately, I'm still seeing the same thing with virtualbox even after updating minikube to v.0.34.1.

jhenriquez commented 5 years ago

What is suggested in this serverfault answer seems to have done it for me using kvm. I've set an static ip for "minikube" on the "minikube-net".

Something interesting about this issue is that it was working fine for me without doing anything before. It started happening after switching OS (from archlinux to xubuntu 18.10).

Also upgraded minikube from 0.33.x to 0.34.1

antoncohen commented 5 years ago

Sorry if I'm poking my head into a place it doesn't belong, but it seems like people are searching for a way to do this, so I wanted to point out some prior art. Vagrant has supported static IPs across VM providers and host OSs for as long was they have supported multiple VM providers and host OSs (they don't have built-in support for all the VM providers minikube supports).

It is basically done by creating a new network interface with a static IP. Under the hood Vagrant knows how to create those interfaces across host OSs, and how to link those interfaces into multiple VM providers.

For me personally, as someone who creates development environments that get used across engineering teams, I would rather have a static IP that is known ahead of time than a dynamic IP that doesn't change after being assigned. By having a static IP I can document that IP, it is consistent across developer workstations, and I can even have it added to DNS or /etc/hosts so there are hostnames associated with the IP.

jorgecuesta commented 5 years ago

I solve it inspired on mac version of remove leases. I test it in Xubuntu 18.10 with VirtualBox 6.

#!/usr/bin/env bash

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

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

minikube_reset_vbox_dhcp_leases
alphabt commented 5 years ago

I'm also having this issue on minikube 0.34.1 with hyperkit in macOS. PR #3572 didn't fix it for me. I had to resort to deleting entries in /private/var/db/dhcpd_leases.

maicohjf commented 5 years ago
  1. Set configuration context $ kubectl config use-context k8s List all PVs sorted by name, saving the full kubectl output to /opt/KUCC0010/my_volumes . Use kubectl s own functionally for sorting the output, and do not manipulate it any further. Question weight 3% Answer: $kubectl get pv --all-namespaces --sort-by="metadata.name" >> /opt/KUCC0010/my_volumes or $kubectl get pv --all-namespaces --sort-by="spec.capacity.storage" >> /opt/KUCC0010/my_volumes
marxangels commented 5 years ago

C:\Users\trump\.VirtualBox\HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter-Dhcpd.leases

using vbox under win10, just edit such file, change the ip and restart minikube.

matti commented 5 years ago

hyperkit has uuid which is used in MAC address generation, when you start the machine with UUID like

minikube start -p makkara-1 --vm-driver hyperkit --uuid 00000000-0000-0000-0000-000000000001 --cpus 12 --memory 2048

the MAC address stays the same even if you delete the machine - the IP addresses can be changed in /var/db/dhcpd_leases the address must be in 192.168.64.xx because /Library/Preferences/SystemConfiguration/com.apple.vmnet.plist sets the address range. I haven't tried changing that range.

stafot commented 5 years ago

Based on comments https://github.com/kubernetes/minikube/issues/951#issuecomment-467044217 , https://github.com/kubernetes/minikube/issues/951#issuecomment-458238635 I created a multi OS support variant of the "workaround" script because I needed to support both MacOS and Linux systems. Is here for anyone might find it useful.

esbol-moldrakhmetov commented 5 years ago

Maybe I can help someone else. First I put VBox 6.* and then I had a problem with changing the ip address, then I made downgrade on VBox 5.2.

pietervogelaar commented 5 years ago

A bit heavy handed way to guarantee minikube gets 192.168.99.100 everytime with virtualbox.

function minikube_reset_vbox_dhcp_leases() {
  # # Reset Virtualbox DHCP Lease Info
  common_message_print "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

I experienced a bit unstable VirtualBox Manager (GUI) with this.

strowi commented 5 years ago

hi,

for anyone interested, i worked around this with a simple static ip. Disadvantage is, its not returned with "minikube ip". But since i can configure it thats not a big problem.. minikube ssh "sudo ifconfig eth0:0 192.168.99.200"

regards, strowi

tstromberg commented 4 years ago

Marking as a backlog item, because I don't believe this will be likely possible to do consistently across hypervisors until we migrate away from libmachine to something like terraform.

fredalbino commented 4 years ago

This is still an ongoing thing for me as well. Do we have any additional information in regards to this?

pwhissell commented 4 years ago

The lease deletion workaround implemented as a bash script for ubuntu users:

minikube stop
mkdir ~/.config/VirtualBox/leasebackup/
mv ~/.config/VirtualBox/*.leases ~/.config/VirtualBox/leasebackup/
mv ~/.config/VirtualBox/*.leases-prev ~/.config/VirtualBox/leasebackup/
VBoxManage hostonlyif remove vboxnet0

-- edit: All vms and vbox services must be shutdown before restarting minikube

medyagh commented 4 years ago

on docker driver we could do this : https://github.com/kubernetes/minikube/issues/7756

I would be happy for anyone who like to pick that issue first for docker driver, and then later we could do same logic for KVM and virtualbox

tstromberg commented 4 years ago

I'm closing this admittedly popular, but overly broad issue, because it is effectively unsolvable for all drivers we interact with.

It is not currently a priority for the maintainers to address this issue, but PR's are certainly welcome to introduce predictable IP support for a particular driver. I caution that doing so may be tricky, particularly when running multi-cluster and/or multi-node configurations.

matti commented 4 years ago

Not for hyperkit - setting UUID works.

On 23. Apr 2020, at 20.28, Thomas Strömberg notifications@github.com wrote:

 Closed #951.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.