Installation
This guide covers installation methods for LXC AutoScale ML.
Quick Installation
The recommended method uses the installation script:
curl -sSL https://raw.githubusercontent.com/fabriziosalmi/proxmox-lxc-autoscale-ml/main/install.sh | bashThis script:
- Verifies system requirements
- Installs Python dependencies via apt
- Downloads application files to
/usr/local/bin/lxc_autoscale_ml/ - Creates configuration directory at
/etc/lxc_autoscale_ml/ - Installs systemd service files
- Enables and starts all services
Manual Installation
For environments requiring manual installation:
Step 1: Install Dependencies
apt update
apt install -y git python3-flask python3-requests python3-sklearn \
python3-pandas python3-numpy python3-aiofiles python3-yaml \
python3-psutil python3-aiohttpOptional Prometheus metrics support:
apt install -y python3-prometheus-clientStep 2: Clone Repository
git clone https://github.com/fabriziosalmi/proxmox-lxc-autoscale-ml.git /tmp/lxc-autoscale-mlStep 3: Install Application Files
mkdir -p /usr/local/bin/lxc_autoscale_ml
cp -r /tmp/lxc-autoscale-ml/lxc_autoscale_ml/* /usr/local/bin/lxc_autoscale_ml/
chmod +x /usr/local/bin/lxc_autoscale_ml/*/*.pyStep 4: Create Configuration Directory
mkdir -p /etc/lxc_autoscale_ml
cp /etc/lxc_autoscale_ml/lxc_autoscale_api.yaml /etc/lxc_autoscale_ml/
cp /etc/lxc_autoscale_ml/lxc_autoscale_ml.yaml /etc/lxc_autoscale_ml/
cp /etc/lxc_autoscale_ml/lxc_monitor.yaml /etc/lxc_autoscale_ml/Step 5: Install Systemd Services
Create /lib/systemd/system/lxc_autoscale_api.service:
[Unit]
Description=LXC AutoScale API Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/bin/lxc_autoscale_api/lxc_autoscale_api.py
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.targetCreate /lib/systemd/system/lxc_monitor.service:
[Unit]
Description=LXC Monitor Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/bin/lxc_monitor.py
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.targetCreate /lib/systemd/system/lxc_autoscale_ml.service:
[Unit]
Description=LXC AutoScale ML Service
After=network.target lxc_autoscale_api.service lxc_monitor.service
[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/bin/lxc_autoscale_ml/lxc_autoscale_ml.py
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.targetStep 6: Enable and Start Services
systemctl daemon-reload
systemctl enable lxc_autoscale_api lxc_monitor lxc_autoscale_ml
systemctl start lxc_autoscale_api lxc_monitor lxc_autoscale_mlPost-Installation Configuration
Set API Key
Generate a secure API key:
openssl rand -hex 32Edit /etc/lxc_autoscale_ml/lxc_autoscale_api.yaml:
authentication:
enabled: true
api_keys:
- "your-generated-key-here"Restart the API service:
systemctl restart lxc_autoscale_apiConfigure LXCFS
Edit /lib/systemd/system/lxcfs.service and add the -l flag:
ExecStart=/usr/bin/lxcfs /var/lib/lxcfs -lApply changes:
systemctl daemon-reload
systemctl restart lxcfsRestart LXC containers for the change to take effect.
Verify Installation
Check Service Status
systemctl status lxc_autoscale_api
systemctl status lxc_monitor
systemctl status lxc_autoscale_mlTest API Health
curl http://localhost:5000/health/checkCheck Metrics Collection
ls -la /var/log/lxc_metrics.jsonView Logs
journalctl -u lxc_autoscale_ml -n 20Log rotation
The installer configures no logrotate stanza, and most logs do not need one:
| Log | Rotated by |
|---|---|
/var/log/lxc_autoscale_ml.log | the model itself, at 10 MB, 5 kept |
/var/log/lxc_monitor.log | the monitor itself, per logging.log_max_bytes |
/var/log/lxc_autoscale_api_access.log | nothing |
/var/log/lxc_autoscale_api_error.log | nothing |
Only gunicorn's two logs are unmanaged. If you keep them as files rather than sending them to the journal, create /etc/logrotate.d/lxc-autoscale-api:
/var/log/lxc_autoscale_api_*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
systemctl reload lxc_autoscale_api > /dev/null 2>&1 || true
endscript
}lxc_autoscale_api is the only unit with an ExecReload. Do not add the model or the monitor to a postrotate reload: they have none, and rotating their files externally fights the rotation they already do.
Alternatively set gunicorn.access_log_file and gunicorn.error_log_file to "-" in lxc_autoscale_api.yaml, which sends both to the journal and removes the need for logrotate entirely.
Troubleshooting Installation
Service Fails to Start
Check logs for errors:
journalctl -u lxc_autoscale_api -n 50 --no-pagerCommon issues:
- Missing Python packages: Run
apt install python3-<package> - Permission errors: Verify file ownership is root
- Port conflict: Check if port 5000 is in use
Cannot Connect to API
# Check if service is listening
ss -tlnp | grep 5000
# Test from localhost
curl -v http://127.0.0.1:5000/health/checkMetrics Not Being Collected
# Check monitor service
systemctl status lxc_monitor
# Check for running containers
pct list
# Check metrics file
cat /var/log/lxc_metrics.json | headNext Steps
- Configuration: Customize settings
- Upgrading: Upgrade from previous versions
