aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2024-09-26 11:53:02 -0400
committerXe Iaso <me@xeiaso.net>2024-09-26 11:53:02 -0400
commitdc65a8a80a3511bfaf8a9d3adba732783dff8306 (patch)
treece9908fdd0fce9b6899f99fbc30a61ae2c300462
parentac0bc4af9d87152c0e2fca5e22a0d5df9296de17 (diff)
downloadxesite-dc65a8a80a3511bfaf8a9d3adba732783dff8306.tar.xz
xesite-dc65a8a80a3511bfaf8a9d3adba732783dff8306.zip
notes: kubevirt networking fix for Ubuntu
Signed-off-by: Xe Iaso <me@xeiaso.net>
-rw-r--r--lume/src/notes/2024/kubevirt-ubuntu-networking.mdx45
1 files changed, 45 insertions, 0 deletions
diff --git a/lume/src/notes/2024/kubevirt-ubuntu-networking.mdx b/lume/src/notes/2024/kubevirt-ubuntu-networking.mdx
new file mode 100644
index 0000000..33fae23
--- /dev/null
+++ b/lume/src/notes/2024/kubevirt-ubuntu-networking.mdx
@@ -0,0 +1,45 @@
+---
+title: "Fixing Kubevirt networking not working on reboot"
+date: 2024-09-26
+desc: "Turns out randomizing the MAC address on boot is a bad idea"
+---
+
+When you use Ubuntu on Kubevirt like I do, rebooting a VM or manually rescheduling pods means that the MAC address in the VM changes. This makes Ubuntu's netplan very unhappy and will result in your VM not acquiring an IP address over DHCP. This is not good for uptime.
+
+After searching the GitHub issue tracker, I found [this comment](https://github.com/kubevirt/kubevirt/issues/1646#issuecomment-433262034) from 2018 that suggested adding this netplan configuration file to the VM:
+
+```yaml
+network:
+ version: 2
+ ethernets:
+ id0:
+ dhcp4: true
+ match:
+ name: enp*
+```
+
+This does the trick, so my minimal cloud-init config for Ubuntu on Kubevirt VM looks like this:
+
+```yaml
+#cloud-config
+hostname: noble
+ssh_pwauth: True
+disable_root: false
+
+write_files:
+ - encoding: b64
+ content: bmV0d29yazoKICB2ZXJzaW9uOiAyCiAgZXRoZXJuZXRzOgogICAgaWQwOgogICAgICBkaGNwNDogdHJ1ZQogICAgICBtYXRjaDoKICAgICAgICBuYW1lOiBlbnAqCg==
+ owner: root:root
+ path: /etc/netplan/99-net-fix.yaml
+ permissions: '0644'
+
+users:
+ - name: xe
+ groups: [ wheel ]
+ sudo: [ "ALL=(ALL) NOPASSWD:ALL" ]
+ shell: /bin/bash
+ ssh_import_id:
+ - gh:xe
+```
+
+I've done reboot testing with my virtual machines and this seems to work consistently enough.