README.md (1656B)
1 # eBPF Lab 2 This is a lab environment with example code from the book Learning eBPF by Liz 3 Rice: https://github.com/lizrice/learning-ebpf 4 5 ## Lab Environment 6 A packer configuration was created in the `packer` folder to build and 7 configure a Centos 9 stream VM with: 8 * bcc (https://github.com/iovisor/bcc) 9 * bpftool (https://github.com/libbpf/bpftool) 10 * bpftrace (https://github.com/iovisor/bpftrace) 11 12 Unfortunately, some blockers (broken functionality, missing features) were 13 encountered pretty early in the eBPF learning process when using the pre-built 14 software from the distribution repositories. Therefore, most recent components 15 are built from the main branch with the idea of a reproducible lab environment. 16 17 The Packer build allows to reproduce and develop the Lab image. To create the 18 qemu image with Packer: 19 ``` 20 cd packer 21 packer build libvirt-centos9.pkr.hcl 22 ``` 23 24 ## Setup and Connect to Lab VM 25 26 Configure location of qemu image: 27 ``` 28 qemuimg=output/centos9-20230512-132055/centos9-20230512-132055.qcow2 29 ``` 30 31 Create the KVM lab VM: 32 ``` 33 sudo virt-install --name ebpf-lab --description "eBPF Lab" \ 34 --osinfo=centos-stream9 --ram=4096 --vcpus=2 \ 35 --disk path=$qemuimg --boot hd --wait 0 --autostart 36 ``` 37 38 Create a sample ssh config: 39 ``` 40 domip=$(sudo virsh -q domifaddr ebpf-lab | awk '{print $4}' | cut -d/ -f 1) 41 42 cat << EOF > ssh-config 43 Host ebpf-lab 44 HostName $domip 45 User root 46 EOF 47 ``` 48 49 Connect to the VM with password `root`: 50 ``` 51 ssh ebpf-lab -F ssh-config 52 ``` 53 54 ## Usage 55 * Work as the root user 56 57 ## Lab cleanup 58 Remove the VM and associated resource: 59 ``` 60 sudo virsh destroy ebpf-lab 61 sudo virsh undefine ebpf-lab 62 rm ssh-config 63 rm $qemuimg 64 ```