A robust, performant VM runner and service built with Deno for creating, managing, and orchestrating virtual machines.
- VM Lifecycle Management: Create, start, stop, pause, resume, snapshot, and restore VMs via libvirt integration
- Resource Management: Efficient CPU, memory, and storage allocation using KVM/QEMU
- Network Management: Advanced networking with DHCP, DNS, and virtual switching
- Storage Management: ZFS integration, snapshots, and shared storage support
- Security: Role-based access control, authentication, and encryption
- API Support: REST and gRPC APIs for integration
- Monitoring: Real-time metrics, logging, and alerting with centralized logging
- High Availability: Kubernetes integration and cluster management
- Backup & Recovery: Scheduled backups and point-in-time recovery
- Template Management: Predefined VM templates for rapid deployment
- Deno 1.34.0 or higher
- libvirt/QEMU for VM management
- ZFS (optional) for advanced storage features
- Kubernetes (optional) for orchestration
- Clone the repository:
git clone https://github.com/layerdynamics/deno-vm.git
cd deno-vm- Install dependencies:
# Unix/Linux
./scripts/install.sh
# Windows
.\scripts\setup.ps1- Configure the environment using our templates:
# Basic development template:
{
"name": "dev-vm",
"description": "Development VM with extra resources",
"cpu": 2,
"memory": 4096,
"disk": [
{
"path": "/vms/${vm_name}/disk0",
"size": 50,
"format": "qcow2"
}
],
"network": {
"mode": "Bridged",
"interfaces": [
{
"type": "virtio",
"macAddress": "auto"
}
]
}
}Create a VM with our VMManager:
// Using VMManager from src/core/execution/vmManager.ts
const vmConfig = {
id: "vm-123",
name: "myvm",
cpu: 2,
memory: 2048,
disk: [{ path: "/vms/myvm/disk0", size: 20, format: "qcow2" }],
network: {
mode: "NAT",
interfaces: [{ macAddress: "auto" }]
}
};
await vmManager.createVM(vmConfig);Create a snapshot:
// Using VMManager's snapshot functionality
await vmManager.snapshotVM("vm-123", "snapshot1");Create a VM via REST API:
curl -X POST http://localhost:8000/api/v1/vms \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "myvm",
"cpu": 2,
"memory": 2048,
"disk": ["disk0:20:qcow2"],
"network": {
"mode": "NAT",
"interfaces": [{"macAddress": "auto"}]
}
}'{
"basic": {
"name": "basic-vm",
"description": "Basic VM template with minimal resources",
"cpu": 1,
"memory": 1024,
"disk": [
{
"path": "/vms/${vm_name}/disk0",
"size": 10,
"format": "qcow2"
}
],
"network": {
"mode": "NAT",
"interfaces": [
{
"type": "virtio",
"macAddress": "auto"
}
]
},
"baseImage": "ubuntu-20.04-minimal"
}
}{
"development": {
"name": "dev-vm",
"description": "Development VM with extra resources",
"cpu": 2,
"memory": 4096,
"disk": [
{
"path": "/vms/${vm_name}/disk0",
"size": 50,
"format": "qcow2"
}
],
"network": {
"mode": "Bridged",
"interfaces": [
{
"type": "virtio",
"macAddress": "auto"
}
]
],
"baseImage": "ubuntu-20.04-desktop"
}
}Our security implementation includes:
// From src/service/security/auth.ts
export async function authenticate(ctx: RouterContext, next: () => Promise<unknown>) {
const authHeader = ctx.request.headers.get('Authorization');
if (!authHeader || !authHeader.startsWith('Bearer ')) {
logger.warn('API: Unauthorized access attempt detected.');
ctx.response.status = 401;
ctx.response.body = { success: false, error: 'Unauthorized' };
return;
}
// ...existing code...
}Real-time metrics collection using our MetricsCollector:
// From src/utils/common.ts
const metrics = await metricsCollector.collectMetrics();
// Returns CPU, memory, disk, and network metricsDeno-VM implements several key components:
- VM Management through LibvirtHypervisor:
// From src/core/execution/libvirt.ts
export class LibvirtHypervisor implements HypervisorInterface {
// ...existing code...
}- Container Management:
// From src/core/execution/containerManager.ts
export class ContainerManager {
// ...existing code...
}- Network Management:
// From network management implementations
class NetworkManager {
// ...existing code...
}For detailed architecture information, see Architecture Documentation.
# Install development dependencies
deno task setup-dev
# Run tests
deno task test
# Run linter
deno task lint- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
For security concerns, please see Security Documentation or contact security@your-domain.com.
This project is licensed under the MIT License - see the LICENSE file for details.
- File an issue on GitHub
- Join our Discord community
- Email support: support@your-domain.com
- GPU passthrough support
- Enhanced network QoS
- Multi-region support
- Advanced monitoring features
- Container integration
- List of contributors
- How to contribute
- Code of conduct
- Deno community
- libvirt project
- Contributors and supporters