A simple, ephemeral VyOS router VM for KubeVirt using the containercraft/vyos:rolling image.
This example deploys a basic VyOS router with:
- eth0: WAN interface (connected to Multus br1 network - upstream)
- eth1: LAN interface (connected to Multus br0 network - downstream)
- NAT from LAN to WAN
- DHCP server for LAN (192.168.1.0/24)
- DNS forwarding
- Basic firewall rules
- SSH access on port 2222
┌─────────────────────────────────────┐
│ Kubernetes Cluster │
│ │
│ ┌───────────────────────────────┐ │
│ │ VyOS Router VM │ │
│ │ │ │
│ │ ┌─────────┐ ┌─────────┐ │ │
│ │ │ eth0 │ │ eth1 │ │ │
│ │ │ (WAN) │ │ (LAN) │ │ │
│ │ │ DHCP │ │192.168 │ │ │
│ │ │ │ │ .1.1 │ │ │
│ │ └────┬────┘ └────┬────┘ │ │
│ │ │ │ │ │
│ └───────┼──────────────┼────────┘ │
│ │ │ │
│ ┌─────▼───┐ ┌────▼─────┐ │
│ │ Multus │ │ Multus │ │
│ │ br1 │ │ br0 │ │
│ └─────────┘ └──────────┘ │
│ (WAN/ (LAN/ │
│ Upstream) Downstream) │
└─────────────────────────────────────┘
- KubeVirt installed on your Kubernetes cluster
- Multus CNI installed and configured
- Linux bridge interfaces on your nodes:
br1- WAN/upstream bridge (must exist on nodes)br0- LAN/downstream bridge (must exist on nodes)
- kubectl with access to the cluster
- virtctl for console access (optional)
Note: The deploy.sh script will automatically create the required NetworkAttachmentDefinitions (wan-br1 and lan-br0) that reference the node bridges br1 and br0.
-
WAN (eth0):
- Connected to Multus br1 network
- DHCP client (gets IP from upstream network)
- Firewall: Drop all incoming, allow established/related
- SSH rate limiting enabled
-
LAN (eth1):
- Static IP:
192.168.1.1/24 - DHCP range:
192.168.1.100-192.168.1.200 - DNS forwarding to 1.1.1.1 and 8.8.8.8
- Domain:
home.arpa
- Static IP:
-
NAT: Masquerade LAN traffic to WAN
- Port:
2222 - Authentication: SSH key only (password auth disabled)
- Public key is configured in
cloud-config.userdata
cd examples/vyos-basic
./deploy.sh# Create NetworkAttachmentDefinitions
kubectl apply -f net-attach-def-wan-br1.yaml
kubectl apply -f net-attach-def-lan-br0.yaml
# Create the cloud-init secret
kubectl create secret generic vyos-basic-config \
--from-file=userdata=cloud-config.userdata
# Deploy the VM
kubectl apply -f vyos-vm.yaml
# Wait for the VM to be ready
kubectl wait --for=condition=Ready vm/vyos-basic --timeout=300s
# Check status
kubectl get vm,vmi vyos-basic
kubectl get net-attach-def# Using virtctl
virtctl console vyos-basic
# Using kubectl
kubectl virt console vyos-basicOnce the VM is running and has an IP address:
# Get the VM's IP address
kubectl get vmi vyos-basic -o jsonpath='{.status.interfaces[0].ipAddress}'
# Connect via SSH
ssh -p 2222 vyos@<vm-ip>Edit cloud-config.userdata to change:
- LAN subnet and DHCP range
- DNS servers
- Firewall rules
- Additional VLANs or interfaces
Edit vyos-vm.yaml and update the network references:
# WAN network (eth0)
- name: eth0
multus:
networkName: br1 # Change this
# LAN network (eth1)
- name: eth1
multus:
networkName: br0 # Change thisThe VM uses docker.io/containercraft/vyos:rolling by default. To use a different version:
- name: containerdisk
containerDisk:
image: docker.io/containercraft/vyos:your-tag# In VyOS console
show interfaces
show ip addressshow dhcp server leases
show dhcp server statisticsshow nat source rules
show nat source statisticsshow firewall
show firewall statistics# Check VM events
kubectl describe vm vyos-basic
# Check VMI (VirtualMachineInstance)
kubectl describe vmi vyos-basic
# Check pod logs
kubectl logs virt-launcher-vyos-basic-xxxxx# In VyOS console
show log tail
show configuration commands | grep interface
ping 1.1.1.1# Check cloud-init status in VyOS
show log cloud-init
# Verify secret exists
kubectl get secret vyos-basic-config -o yaml# Delete the VM
kubectl delete vm vyos-basic
# Delete the secret
kubectl delete secret vyos-basic-config
# Delete NetworkAttachmentDefinitions
kubectl delete -f net-attach-def-wan-br1.yaml
kubectl delete -f net-attach-def-lan-br0.yaml- This is an ephemeral deployment using containerDisk
- Configuration is applied via cloud-init on every boot
- No persistent storage is used
- Perfect for testing and development
- For production use, consider persistent storage for configuration
- Add more interfaces for DMZ, IoT, etc.
- Configure VLANs on eth1
- Set up VPN (WireGuard, IPsec)
- Enable monitoring and logging
- Add static DHCP leases
- Configure port forwarding rules