Projet

Général

Profil

Cluster with libvirt » Historique » Version 15

« Précédent - Version 15/22 (diff) - Suivant » - Version actuelle
Laurent GUERBY, 28/06/2020 15:34


Cluster with libvirt

Tooling


# cd /root/tools/libvirt/

# ./autovirsh domuuid gizmo.sileht.net
Domain gizmo.sileht.net is on g3
4baace2f-6d7c-4575-8982-bedb6065ab6b

# ./where www.tetaneutral.net
Domain www.tetaneutral.net is on g1

# ./create-vm --help
usage: create-vm --ip IP NAME
       --image debian-buster-scsi
       --ram 1     # SIZE in GiB
       --vcpu 1
       --ip <IPV4>
       --disk 20   # SIZE in GiB
       --on g1       # short name of the host

# ./migrate --help
usage: migrate NAME DEST

# ./info gizmo.sileht.net
Domain gizmo.sileht.net is on g3
Interface  Type       Source     Model       MAC
-------------------------------------------------------
tap249cbb03-b8 ethernet   -          virtio      fa:16:3e:88:4d:0b

Target     Source
------------------------------------------------
hda        ssds/97c925e4-9f3e-4b92-96b9-6190e0fc4b88_disk.config
sda        ssds/volume-0973c10d-79c8-4906-9f9c-9ba33118203d
sdb        disks/volume-3657e47a-07d8-4052-8dcf-cb7a0fb19b20

<config>
  <tap name="tap249cbb03-b8">91.224.149.214</tap>
</config>

Fontionnement

Les VM utilisent le mode ethernet de libvirt. En gros libvirt s'attends à trouver un tap tout près pour y accrocher la VM

Just avant le boot de la VM libvirt lance:

 /etc/libvirt/hooks/qemu <VM_NAME> prepare begin

Et juste après l'arret de la VM libvirt lance:

 /etc/libvirt/hooks/qemu <VM_NAME> release end

Le script /etc/libvirt/hooks/qemu de ttnn se trouve ici: https://chiliproject.tetaneutral.net/projects/git-tetaneutral-net/repository/puppetmaster/revisions/master/entry/environments/production/manifests/files/openstack/libvirt-hooks-qemu

Ce script va lire les metadatas TTNN de <VM_NAME> (e.g: virsh metadata <VM_NAME> http://tetaneutral.net/)

$ virsh metadata ns2.tetaneutral.net http://tetaneutral.net/
<config>
  <network mode="routed">
    <tap name="tapb0b4a106-d0">89.234.156.248</tap>
    <tap name="tapabababab-aa">89.234.156.45</tap>
  </network>
</config>

Ensuite il va créé le tap et configurer les routes dessus avec les infos des metadata.

git

https://chiliproject.tetaneutral.net/projects/git-tetaneutral-net/repository/openstack-tools

libvirt

Misc

Editer le disque d'une VM

Mode lecture seule (sans danger) :

VM=xxx
virsh shutdown $VM
virsh destroy $VM # si shutdown marche pas
guestfish --ro -i -d $VM

Pour par exemple desactiver cloud-init qui peut bloquer le boot :

guestfish -i -d $VM
ll /etc/cloud
touch /etc/cloud/cloud-init.disabled
exit