KVM with n8n - Installation using entirius-scripts-kvm-deployer
This guide describes the installation and deployment of n8n instances in a KVM environment using the entirius-scripts-kvm-deployer scripts.
This guide assumes you have completed:
- KVM Server Install - Ubuntu 24.04 server with KVM, HAProxy, and WebVirtCloud
Ubuntu 24.04 server with KVM installed and configured according to KVM Server Install guide, which includes:
- Ubuntu 24.04 cloud image at
/var/lib/libvirt/images/ubuntu-24.04-server-cloudimg-amd64.img - entirius-scripts-kvm-deployer repository cloned at
~/entirius-scripts-kvm-deployer - SSH key pair generated for the vm-admin user
- vm-admin user with membership in groups: sudo, libvirt, www-data
Install required packages
ssh vm-admin@your-server-address
sudo apt update
sudo apt install -y qemu-kvm libvirt-daemon-system virtinst guestfs-tools gettext-base
Navigate to entirius-scripts-kvm-deployer
cd ~/entirius-scripts-kvm-deployer git pullCopy the example configuration file and customize it:
cp n8n-deploy.config.example n8n-deploy.config vim n8n-deploy.configConfigure the following variables in
n8n-deploy.config:# Configuration file for the n8n-deploy.sh script # Copy this file and customize it for your environment # Domain configuration (used by n8n) # Set your real domain or use the VM's IP address after installation DOMAIN="n8n.yourdomain.com" # Virtual machine name VM_NAME="vm-company-production-n8n" # Virtual machine configuration BASE_IMAGE_URL="https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img" TEMPLATE_IMAGE="ubuntu-24.04-server-cloudimg-amd64.img" VM_STORAGE_PATH="/var/lib/libvirt/images" VM_MEMORY=4096 # in MB VM_VCPUS=2 VM_DISK_SIZE="25G" # Disk size for the new machine # SSH Configuration # Make sure this file exists. # It will be used to log into the machine. SSH_KEY_FILE="$HOME/.ssh/id_ed25519.pub" # Set these variables to connect n8n to your PostgreSQL database DB_HOST="localhost" DB_PORT="5432" DB_NAME="n8n" DB_USER="n8n" DB_PASSWORD="your_strong_password" DB_SCHEMA="public"SSH Key Setup
Ensure you have SSH key pair generated (should already exist from KVM setup):
# Verify SSH keys exist: ls -la ~/.ssh/ # If you don't have SSH keys, generate them (using ED25519 per ADR-018): ssh-keygen -t ed25519 -C "[email protected]"
Deploy n8n instance, it will take 5 mins
./n8n-deploy.shYou can connect to the console to view the progress
virsh console vm-company-production-n8n
Querying the IP address of an instance
sudo virsh list --all sudo virsh domifaddr vm-company-production-n8nSSH by IP
Check the Systemd Service Status
sudo systemctl status n8nYou should see an Active: active (running) status
Review Detailed Service Logs
# Display the full logs for the n8n service sudo journalctl -u n8n # Display the last 100 log entries and follow the log in real-time sudo journalctl -u n8n -n 25 -fVerify the Network Port
sudo ss -tlpn | grep ':80'Expected Output
LISTEN 0 511 *:80 0.0.0.0:* users:(("node",pid=1239,fd=21))
Add ip to /etc/hosts
Querying the IP address of an instance
sudo virsh list --all sudo virsh domifaddr vm-company-production-n8nsudo vim /etc/hosts# VMs 192.168.122.xx vm-company-production-n8n# Test configuration syntax sudo haproxy -f /etc/haproxy/haproxy.cfg -c # Reload HAProxy with new configuration sudo systemctl reload haproxy # Check HAProxy status sudo systemctl status haproxy
