diff --git a/Agent Instance.md b/Agent Instance.md index 50d30a1..671acdb 100644 --- a/Agent Instance.md +++ b/Agent Instance.md @@ -1,4 +1,84 @@ -# Fonctionnement des vms +## Fonctionnement des vms + +### Structure de demande de creation de VM + +```go +type Volume struct { + path string `/ou/ce/trouve/le/fichier/qcow2` + position int `[0-9]*` +} + +type Network struct { + vxlanid int `0-2000000` + netname string `vpc-[0-1,a-z]10` + subnetname string `subnet-[0-1,a-z]10` + position int `[0-9]*` + ipV4 string + gatewayV4 string + ipV6 string + gatewayV6 string +} + +type NetRule struct { + proto string + port int + source string + destination string +} + +type VmConfig struct { + Id string `i-[0-9]10` + Volumes Volume[] + Networks Network[] + MemoryMB int + CPUs int + Rules NetRule[] + Keys string[] +} +``` + +### Structure de gestion des ressources + +```go +vm_list + volume_list + metadata_server + network_id_info +subnet_list + vm_id_list +``` + +### ordre d'execution + +``` +Create_VM: + add vm in list, state pending + if subnet do not exist: <- does not exist if not il list + if network do not exist: <- does not exist if we do not have a subnet in it + add network in list, state pending + create netns + create veth + create internal_bridge + set network, state created + create tap + launch metadata/dhcp server + if qcow2 file does not exist <- simple file check + create qcow2 files + start vm + set vm on running + +Delete_VM: + stop vm + stop metadata/dhcp server + remove tap + if last vm in subnet + delete subnet + delete veth + if last subnet in net + delete net + remove subnet from list + remove vm form list +``` ## Demarrage @@ -47,7 +127,7 @@ func StartVM(cfg VMConfig) (*VMInstance, error) { "-name", cfg.Name, "-m", fmt.Sprintf("%d", cfg.MemoryMB), "-smp", fmt.Sprintf("%d", cfg.CPUs), - "-drive", fmt.Sprintf("file=%s,format=qcow2,if=virtio", cfg.ImagePath), + "-drive", fmt.Sprintf("file=%s,format=qcow2,if=virtio,index=0", cfg.ImagePath), "-netdev", fmt.Sprintf("tap,id=net0,ifname=%s,script=no,downscript=no", cfg.TapIfName), "-device", "virtio-net-pci,netdev=net0", "-qmp", fmt.Sprintf("unix:%s,server,nowait", qmpSock), diff --git a/Agent KVM.md b/Agent KVM.md index e8b5385..c077242 100644 --- a/Agent KVM.md +++ b/Agent KVM.md @@ -25,4 +25,5 @@ Tout cela serait lancer depuis une api: ## Architecture -![archi image](./images/agent_archi.drawio.svg) \ No newline at end of file +![archi image](./images/agent_archi.drawio.svg) +![kvm image](./images/kvm_archi.drawio.svg) \ No newline at end of file diff --git a/Home.md b/Home.md index 856d54d..b9cd836 100644 --- a/Home.md +++ b/Home.md @@ -1,4 +1,4 @@ -# Syonad +# Two Bienvenue sur le wiki du projet syonad _/sjɔ.nad/_ diff --git a/images/kvm_archi.drawio.svg b/images/kvm_archi.drawio.svg new file mode 100644 index 0000000..de96f6d --- /dev/null +++ b/images/kvm_archi.drawio.svg @@ -0,0 +1,614 @@ + + + + + + + + + + + + + +
+
+
+ eth0 +
+
+
+
+ + eth0 + +
+
+
+ + + + + + + +
+
+
+ vxlan-x +
+
+
+
+ + vxlan-x + +
+
+
+ + + + + + + +
+
+
+ vxlan-x +
+
+
+
+ + vxlan-x + +
+
+
+ + + + + + + +
+
+
+ vxlan-x +
+
+
+
+ + vxlan-x + +
+
+
+ + + + + + + +
+
+
+ vxlan-x +
+
+
+
+ + vxlan-x + +
+
+
+ + + + + + + +
+
+
+ br-subnet-y +
+
+
+
+ + br-subnet-y + +
+
+
+ + + + + + + +
+
+
+ br-subnet-y +
+
+
+
+ + br-subnet-y + +
+
+
+ + + + + + + +
+
+
+ br-subnet-y +
+
+
+
+ + br-subnet-y + +
+
+
+ + + + + + + +
+
+
+ br-subnet-y +
+
+
+
+ + br-subnet-y + +
+
+
+ + + + + + + +
+
+
+ veth-subnet-y +
+
+
+
+ + veth-subnet-y + +
+
+
+ + + + + + + +
+
+
+ veth-subnet-y +
+
+
+
+ + veth-subnet-y + +
+
+
+ + + + + + + +
+
+
+ veth-subnet-y +
+
+
+
+ + veth-subnet-y + +
+
+
+ + + + + + + +
+
+
+ veth-subnet-y-ext +
+
+
+
+ + veth-subnet-y-ext + +
+
+
+ + + + + + + +
+
+
+ netns-z +
+
+
+
+ + netns-z + +
+
+
+ + + + + + + +
+
+
+ veth-subnet-y +
+
+
+
+ + veth-subnet-y + +
+
+
+ + + + + + + +
+
+
+ veth-subnet-y +
+
+
+
+ + veth-subnet-y + +
+
+
+ + + + + + + +
+
+
+ veth-subnet-y +
+
+
+
+ + veth-subnet-y + +
+
+
+ + + + + + + +
+
+
+ veth-subnet-y-int +
+
+
+
+ + veth-subnet-y-int + +
+
+
+ + + + + + + +
+
+
+ br-subnet-y : + + ip 10.0.0.1/32 et 2a::1/128 + +
+ + ip route add 10.0.0.0/24 scope link dev br-subnet-y + +
+
+ + ip -6 route add 2a::0/64 scope link dev br-subnet-y + +
+
+
+
+
+ + br-subnet-y : ip 10.0.0.1/32 et 2a::1/128... + +
+
+
+ + + + + + + +
+
+
+ tap-vm + + -> filtrage bloquant pour le dhcp et le 169.254.168.254 + +
+
+
+
+ + tap-vm -> filtrage bloquant pour le dhcp et le... + +
+
+
+ + + + + + + +
+
+
+ qemu +
+
+
+
+ + qemu + +
+
+
+ + + + + + + +
+
+
+ metadata +
+
+
+
+ + metadata + +
+
+
+ + + + + + + +
+
+
+ dhcp +
+
+
+
+ + dhcp + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ agent +
+
+
+
+ + agent + +
+
+
+ + + + + + + +
+
+
+ frr +
+
+
+
+ + frr + +
+
+
+ + + + + + + + + + + + + + + + +
+
+
+ consul +
+
+
+
+ + consul + +
+
+
+ + + +
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file