Multiple PXE Server On Cloud
Mô hình :

Tất cả VM đều được cấp MAC và IP theo router mà Host đã được cắm vào
Lúc này tất cả máy trong dải IP đều có thể truy cập vào PXE server nằm trên các VM

Các bước triển khai :
Cài đặt Cockpit
Tạo template_volumes
Nhân bản template thành nhiều volume
Khởi tạo VM từ các volume
Cấu hình interface network để được cấp phát IP của router trên các VM ( không dùng Virtual Network )
Cài đặt API
Cài đặt Cockpit
apt update -y
apt install cockpit -y
apt install cockpit-machines -y
apt install libosinfo-bin -y
apt upgrade osinfo-db -y
apt install osinfo-db-tools -y
curl -O https://releases.pagure.org/libosinfo/osinfo-db-20230518.tar.xz
osinfo-db-import --local osinfo-db-20230518.tar.xz
systemctl restart cockpit
systemctl status cockpit
Tạo folder chứa dữ liệu :
mkdir /vm-data
mkdir /vm-data/templates
mkdir /vm-data/volumes
Tạo Storage Pool :
virsh pool-define-as "VM Storage" dir --target /vm-data/volumes
virsh pool-start "VM Storage"
virsh pool-autostart "VM Storage"
virsh pool-list --all
Tải template VM :
wget -P /vm-data/templates/ https://example.com/template.qcow2
Sau khi cài đặt thành công :
Truy cập https://localhost:9090
Thực hiện đăng nhập :
Sử dụng chính user của OS để đăng nhập

Truy cập Terminal ở navbar phía bên trái :

Thực hiện tạo volumes từ template :

Truy cập mục Virtual Machines ở navbar phía bên trái :

Chọn import VM ở góc bên phải và truyền path volume :

Mở detail VM và cấu hình network interface:
Type : Direct attachment
Source : enp3s0 (Interface dải mạng chính)
Model : e1000e (PCI)

Truy cập vào VM check interface đã được cấp mạng theo đúng dải mạng mình cần dùng chưa :

Thực hiện truy cập Iventoy theo IP của VM :

Thực hiện cài đặt API ở thiết bị trên cùng dải mạng :
apt update -y
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
apt install nodejs -y
npm install -g pm2
git clone <Link>
cd api-handle-iventoy
npm install
pm2 start "node index.js" --name api
API list :
Path
Method
Body
Feature
/os
GET
Danh sách OS
/os
POST
{
"name": "Windows 10"
}
Khai báo OS
/devices
GET
Danh sách PXE Server
/devices
POST
{
"ip": "192.168.1.112",
"os": "Windows 10",
"portIventoy": 26000
}
/devices/mac
POST
{
"os": "Windows 10",
"mac": "00-0C-29-85-05-3D"
}
Khai báo mac được chấp nhận cho OS
/devices/mac
DELETE
{
"os": "Windows 10",
"mac": "00-0C-29-85-05-3D"
}
Loại bỏ mac được chấp nhận cho OS
Last updated