Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Libvirt wrapper to spawn VMs using cloud images

License

NotificationsYou must be signed in to change notification settings

kayrus/deploy-vm

Repository files navigation

sudo apt-get install -y libvirt-bin virtinst qemu-kvm virt-manager git wget genisoimagesudo service libvirt-bin start

For the Windows VM support installbsdtar (this tool allows to extract zip archive from stdin):

sudo apt-get install bsdtar

Install on Fedora/CentOS

sudo yum install -y libvirt virt-install qemu-kvm virt-manager git wget genisoimage NetworkManagersudo service libvirtd start

For the Windows VM support installbsdtar (this tool allows to extract zip archive from stdin):

sudo yum install bsdtar

This string inside your~/.profile will allow you to usevirsh:

export LIBVIRT_DEFAULT_URI=qemu:///system

Configure local resolver to use libvirt's dnsmasq

  • Ubuntu 18.04 (systemd-resolved(c))

The setting below is not preserved on reboot:

systemd-resolve --set-dns=192.168.122.1 --set-domain=vm --interface=virbr0

Verify:

systemd-resolve --status virbr0

Add the following section into libvirt default network (sudo virsh net-edit default):

  <domainname='vm'localOnly='yes'/>

And restart the network:

sudo virsh net-destroy defaultsudo virsh net-start default
  • Ubuntu/Debian
virsh net-dumpxml default| sed -r":a;N;\$!ba;s#.*address='([0-9.]+)'.*#nameserver \1#"| sudo tee -a /etc/resolvconf/resolv.conf.d/head&& sudo resolvconf -u
  • Fedora/CentOS
sudo systemctlenable NetworkManagerecho -e"[main]\ndns=dnsmasq"| sudo tee -a /etc/NetworkManager/NetworkManager.confvirsh net-dumpxml default| sed -r":a;N;\$!ba;s#.*address='([0-9.]+)'.*#server=\1\nall-servers#"| sudo tee /etc/NetworkManager/dnsmasq.d/libvirt_dnsmasq.confsudo systemctl restart NetworkManager

Add current user intolibvirt group (will allow you to run scripts withoutsudo)

sudo usermod -aG libvirtd$USER# for Debian/Ubuntu14.04/Ubuntu16.04sudo usermod -aG libvirt$USER# for CentOS/Fedora/Ubuntu18.04

NOTE: You have to relogin into your UI environment to apply these changes.

Allow libvirt to read VMs images in your home directory

ACL solution

Add permissions

setfacl -m"u:libvirt-qemu:--x"$HOME# for Debian/Ubuntusetfacl -m"u:qemu:--x"$HOME# for CentOS/Fedora

Remove permissions

Remove ACL entries only for libvirt
setfacl -m"u:libvirt-qemu:---"$HOME# for Debian/Ubuntusetfacl -m"u:qemu:---"$HOME# for CentOS/Fedora
Remove all custom ACL entries
setfacl -b$HOMEgetfacl$HOME

Groups solution

Add permissions

sudo usermod -aG$USER libvirt-qemu# for Debian/Ubuntusudo usermod -aG$USER qemu# for CentOS/Fedorachmod g+x$HOME

Remove permissions

sudo usermod -G"" libvirt-qemu# for Debian/Ubuntusudo usermod -G"kvm" qemu# for CentOS/Fedorachmod g-x$HOME

Configure virsh environment

echo"export LIBVIRT_DEFAULT_URI=qemu:///system">>~/.bashrc

Configure ~/.ssh/config

cat dot_ssh_config>>~/.ssh/configchmod 600~/.ssh/config

Run Flatcar VMs cluster of 3 nodes

./deploy_flatcar_cluster.sh -s 3

user_data file works only for Flatcar and contains a template for Flatcar configuration and it configuresetcd2 andfleet.

Try out Tectonic

Create Tectonoic credentials files:

  • tectonic.lic # raw base64 encoded licence
  • docker.cfg # raw base64 encoded dockercfg

Deploy cluster:

./deploy_k8s_cluster.sh --tectonic

Enter your Kubernetes master node:

ssh core@k8s-master# [-i ~/.ssh/id_rsa]

Get Tectonicadmin@example.com password:

kubectl --namespace=tectonic-system get secret tectonic-identity-admin-password -o template --template="{{.data.password}}"| base64 -d&&echo

Login Tectonic:

https://k8s-master:32000

Username:admin@example.comPassword: see above

Run other VMs

Linux

Run three CentOS VMs

./deploy_vms_cluster.sh -o centos -s 3

Windows

Run one Windows IE11.Win7 VM

./deploy_vms_cluster.sh -o windows -r IE11.Win7 -m 1024 -u 2

FreeBSD guest (experimental)

Download and run FreeBSD:

./deploy_vms_cluster.sh -o freebsd# for 10.3 RELEASE./deploy_vms_cluster.sh -o freebsd -c 11.0 -r RC1# for 11.0 RC1

FreeBSD QEMU images don't supportcloud-init, so you have to configure network and ssh manually through the console:

dhclient vtnet0echo'sshd_enable=YES'>> /etc/rc.confecho'ifconfig_DEFAULT=DHCP'>> /etc/rc.confecho'PermitRootLogin yes'>> /etc/ssh/sshd_configservice sshd startpasswd

FreeBSD host (experimental)

pkg install bash wget bzip2 gnupg cdrtools libvirt qemu virt-managerkldload vmmlibvirtd -difconfig tap createifconfig bridge createifconfig bridge0 addm tap0 up

virt-install version > 1.4 should use following parameters:

--nographic \--console nmdm,source.master=/dev/nmdm0A,source.slave=/dev/nmdm0B \--network bridge=bridge0 \

and without--vnc flag. VNC flag produces following XML:

<graphicstype="vnc"port="-1"keymap="en-us"/>

which causesinternal error: cannot determine default video type error message.

Completely destroy and remove all related VMs cluster data

./remove_cluster.sh flatcar

About

Libvirt wrapper to spawn VMs using cloud images

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp