I'm transitioning my homelab to run a native Kubernetes stack, and I want to make sure my virtual machines can consistently receive the same IP addresses, even after reboots. Currently, I'm using Kubevirt alongside kubemacpool for MAC address persistence and Multus to manage the default network. However, I'm facing issues because the IP addresses keep changing when VM instances restart. It seems that with the DHCP helper daemon set, a new MAC address is assigned every time a VM launches, leading to new IP assignments. I tried using cloud-init to manage static IPs, but I'd prefer a more automated solution. I'm using a bare metal Gentoo setup with RKE2 (single node), Cilium, and Multus as the CNI. Any advice or solutions would be greatly appreciated!
4 Answers
You might want to check out KubeMacpool. It's specifically designed for managing MAC and IP address persistence for virtual machines in Kubevirt. Here's the link for reference: https://github.com/k8snetworkplumbingwg/kubemacpool
I’ve had success using MetalLB to assign static IPs to my VMs by setting them up behind a load balancer service type in Kubevirt. It works well, but just keep in mind that this involves a little NAT from the pod to the VM, which can create issues for certain services, especially those that depend on layer 2/3 discovery.
Have you tried Kube-OVN? It can help with binding IP addresses directly to your Kubevirt VMs. Here’s some documentation on how it works: https://kubeovn.github.io/docs/stable/en/kubevirt/static-ip/. It might be a good fit for what you’re looking to achieve.
Honestly, I've been stuck in the same boat. I ended up using static IPs configured through cloud-init, since the changing IPs from pods were too unpredictable for my use case. I’ve scripted DNS updates to match, though it's a bit of a hassle. If you want to check out my scripts for ideas, let me know!
I see your point! Did you face any specific challenges with services when using NAT?