From dc65a8a80a3511bfaf8a9d3adba732783dff8306 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Thu, 26 Sep 2024 11:53:02 -0400 Subject: notes: kubevirt networking fix for Ubuntu Signed-off-by: Xe Iaso --- lume/src/notes/2024/kubevirt-ubuntu-networking.mdx | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lume/src/notes/2024/kubevirt-ubuntu-networking.mdx 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. -- cgit v1.2.3