[LINUX] Create a VM with a YAML file (KVM)

Introduction

Wouldn't it be easier if you could build a VM with a YAML file? So, I have created a command called kvm-compose (pseudonym), so I would like to introduce it.

environment

--Centos 8 Minimal installed --Running on VirtualBox --Move with GUI from the middle --It works only with CLI by specifying a bridge that can access the outside.

Update, KVM installation

# dnf update -y
# dnf install -y wget 
# dnf module install -y virt
# dnf module install -y "Server with GUI"  (virt-When using viewer)
# dnf install -y virt-install virt-viewer git wget

Start libvirtd

# systemctl start libvirtd
# systemctl enable libvirtd

Download and configure `` `kvm-compose```

# git clone https://github.com/naoki2001/kvm-compose
# mkdir /compose/{ images , isos }
# wget http://ftp.riken.jp/Linux/centos/8/isos/x86_64/CentOS-8.2.2004-x86_64-minimal.iso
# mv CentOS-8.2.2004-x86_64-minimal.iso /compose/isos/
# startx  (virt-When using viewer)

Building a VM

# cd kvm-compose
# cat kvm-compose.yml

The following formats can work with kvm-compose (although we plan to increase it ...)

kvm-compose.yml


kvm:
  - name: test
    arch: x86_64
    os:
      - type: linux
        variant: rhel8.0
    vcpus: 1
    ram: 1024
    disk:
      - path: /conpose/images/test.img
        format: qcow2
        size: 8
    network:
      - bridge: virbr0
    location: /compose/isos/CentOS-8.2.2004-x86_64-minimal.iso
    extra-args: "console=tty0 console=ttyS0,115200n8"

Each item conforms to virt-install

# ./kvm-compose build

With this, virt-viewer will start in the GUI, so install the OS. For CLI, access with VNC.

kvm-compose -- kvm-compose is created in Go language based on the `virsh``` and `virt-install``` commands. ――What you can do

option Description
build kvm-compose.Load yml and build VM
build file.yml file.Load yml and build VM
list View running VMs
list --inactive Cover of a non-started VM
list --all View all VMs
start vm_name vm_Start name. Start and then return to prompt
shutdown vm_name vm_Shut down name. Return to prompt when you can confirm that the power is off
destroy vm_name vm_Power off name. Return to prompt when you can confirm that the power is turned off

Caution

--If the kvm-compose command does not work Download the source code from https://github.com/naoki2001/kvm-compose-src and try compiling it according to the README.md.

Finally

I was able to build a VM for the time being. However, it is not easy to use, so I would like to improve it. If you find any typographical errors, typographical errors, or missing points, we would appreciate it if you could comment.

Change log

Posted on 10/21 10/24 Addition of functions (start, shutdown, destroy)

Recommended Posts

Create a VM with a YAML file (KVM)
Create a file uploader with Django
Create a large text file with shellscript
Create a PDF file with a random page size
Create a Photoshop format file (.psd) with python
Create a cylinder with open3d + STL file output
Create a homepage with django
Create a dummy data file
Create a heatmap with pyqtgraph
[Python] Create a Tkinter program distribution file with cx_Freeze
Create a directory with python
Create xlsx file with XlsxWriter
Create a 2d CAD file ".dxf" with python [ezdxf]
[Python] Create a file & folder path specification screen with tkinter
Create a virtual environment with Python!
Create an Excel file with Python3
Create a 1MByte random number file
Create a poisson stepper with numpy.random
How to create a config file
Create a temporary file with django as a zip file and return it
The idea of feeding the config file with a python file instead of yaml
Create and return a CP932 CSV file for Excel with Chalice
Create a Python function decorator with Class
Build a blockchain with Python ① Create a class
Create a dummy image with Python + PIL.
[Python] Create a virtual environment with Anaconda
Let's create a free group with Python
Quickly create an excel file with Python #python
Create a GUI app with Python's Tkinter
Create a star system with Blender 2.80 script
Create a virtual environment with Python_Mac version
Create a simple web app with flask
Create Excel file with Python + similarity matrix
Create a word frequency counter with Python 3.4
Create a deb file from a python package
[GPS] Create a kml file in Python
Create a Connecting Nearest Neighbor with NetworkX
Script to create a Mac dictionary file
Create a web service with Docker + Flask
Read a character data file with numpy
Create a private repository with AWS CodeArtifact
Create a car meter with raspberry pi
Create a devilish picture with Blender scripts
Create a matrix with PythonGUI (text box)
I made a configuration file with Python
Create an upgradeable msi file with cx_Freeze
Create a graph with borders removed with matplotlib
Create a frame with transparent background with tkinter [Python]
How to read a CSV file with Python 2/3
Create a GIF file using Pillow in Python
Speaking Japanese with gTTS (reading a text file)
Create an executable file in a scripting language
Create a LINE BOT with Minette for Python
Create a UI that replaces VBA with PySimpleGUI (file dialog, list, log output)
Create a game UI from scratch with pygame2!
How to create a JSON file in Python
Create a virtual environment with conda in Python
Create a page that loads infinitely with python
[Note] Create a one-line timezone class with python
You can easily create a GUI with Python
Create a python3 build environment with Sublime Text3