# vRouter-Operator demo with Harvester (Kubernetes Kubevirt Platoform) ## Github repo https://github.com/tjjh89017/vrouter-operator ## Note This is just a PoC, not production ready ## Demo Video: https://youtu.be/pvdPgob3jAE ## 01 Prepare Harvester Video: https://youtu.be/DUemUdEIJ5A - Install harvester with UEFI (Here we use Proxmox VE to emulate) - Here we use Harvester 1.5.1 (1.6.x should be almost the same as 1.5.1) - Use Tab to select, Use Enter to next item - Wait for it - It will reboot automatically - Wait for it to be ready - Login WebUI with VIP - Download kubeconfig to another Linux with kubectl (Click the left-bottom button `support`) - Create VM Network, please refer to Video You can refer to the following VM conf to check, we have two interfaces here. First one for mgmt interface for Harvester, another one is VM Network. ``` agent: 1 bios: ovmf boot: order=scsi0;ide2;net0 cores: 16 cpu: host efidisk0: qnap:128/vm-128-disk-0.qcow2,efitype=4m,pre-enrolled-keys=1,size=528K ide2: qnap:iso/harvester-v1.5.1-amd64.iso,media=cdrom,size=7116672K machine: q35 memory: 65536 meta: creation-qemu=10.0.2,ctime=1758035493 name: harv-test-1 net0: virtio=BC:24:11:69:5E:54,bridge=vmbr0 net1: virtio=BC:24:11:82:DC:9A,bridge=vmbr0 numa: 0 ostype: l26 scsi0: qnap:128/vm-128-disk-1.qcow2,iothread=1,size=320G scsihw: virtio-scsi-single smbios1: uuid=b4f23b4a-1a32-44f6-819d-1a9af6ff3172 sockets: 1 vmgenid: 8aa605da-f59e-4381-897e-a1cfdff181c3 ``` ## 02 Prepare Operator itself Video: https://youtu.be/N4Ce6v1iUEo - Login to another Linux with kubectl and the kubeconfig - Better to install k9s for better usage to control Kubernetes - git clone vRouter-operator and deploy the operator, by default, you will install my prebuilt image into your Harvester. Please execute the following commands - `git clone https://github.com/tjjh89017/vrouter-operator` - `cd vrouter-operator` - `kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.4/cert-manager.yaml` - `make deploy` - If some error occur, please install operator-sdk in your environment - Check the README to deploy correct RBAC with `kubectl apply -f`, you can just execute the following commands. ```bash cat <<EOF | kubectl apply -f - --- apiVersion: v1 kind: ServiceAccount metadata: labels: name: vrouter-operator-controller-manager namespace: default --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: default-namespace-vrouterconfig-viewer-role-binding subjects: - kind: ServiceAccount name: vrouter-operator-controller-manager namespace: default roleRef: kind: ClusterRole name: vrouter-operator-vrouterconfig-viewer-role apiGroup: rbac.authorization.k8s.io --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: default-namespace-view subjects: - kind: ServiceAccount name: vrouter-operator-controller-manager namespace: default roleRef: kind: ClusterRole name: view apiGroup: rbac.authorization.k8s.io EOF ``` ## 03 Prepare VyOS VM QCOW2 image - Check and follow the README in git repo - https://github.com/tjjh89017/vrouter-operator?tab=readme-ov-file#prepare-vyos-vm-image ## 04 Upload VyOS VM QCOW2 image to Harvester Video: https://youtu.be/mWMwTjiNEko - Please check the video ## 05 Deploy VyOS VM without vRouter-Operator Video: https://youtu.be/mmwNpsJHWjU - Please check the video ## 06 Deploy VyOS VM with vRouter-Operator Video: https://youtu.be/ohKBVfR_9QU - Prepare a config, the following example config will set hostname to `vyos-k8s-demo`, and setup eth0 with dhcp ```bash cat <<EOF | kubectl apply -f - --- apiVersion: vrouter.kojuro.date/v1 kind: VRouterConfig metadata: name: vrouterconfig-sample spec: config: | system { host-name vyos-k8s-demo login { user vyos { authentication { encrypted-password $6$QxPS.uk6mfo$9QBSo8u1FkH16gMyAVhus6fU3LOzvLR9Z9.82m3tiHFAxTtIkhaZSWssSgzt4v4dGAL8rhVQxTg0oAG9/q11h/ plaintext-password "" } } } syslog { global { facility all { level info } facility protocols { level debug } } } ntp { allow-client { address 127.0.0.0/8 address 169.254.0.0/16 address 10.0.0.0/8 address 172.16.0.0/12 address 192.168.0.0/16 address ::1/128 address fe80::/10 address fc00::/7 } server "time1.vyos.net" server "time2.vyos.net" server "time3.vyos.net" } console { device ttyS0 { speed 115200 } } config-management { commit-revisions 100 } } interfaces { loopback lo { } } command: | set interface eth eth0 address dhcp EOF ``` - Prepare a VM with annotation - Please check the video - `vrouter.kojuro.date/config: vrouterconfig-sample` ## 07 Change the config on-the-fly Video: https://youtu.be/6P_zzqxkEIQ - Please check the video - We change the hostname to demo, and delete eth0 dhcp - in k9s, you may need enter `:vrouter.kojuro.date/v1/vrouterconfigs` to select the kind, and press `1` to select namespace `default`, and press `e` to edit (it will give you a VIM editor) - You can still use kubectl to edit them, it's the same.