7.1 KiB
Proxmox LXC Deployment Guide
This guide will help you deploy the QR Code Generator application as an LXC container on Proxmox.
Quick Start
Step 1: Fill Out Configuration
Edit the proxmox-deployment-config.yaml file with your Proxmox environment details:
nano proxmox-deployment-config.yaml
Step 2: Minimum Required Fields
At minimum, you need to configure:
-
Proxmox Host Information:
proxmox.host- Your Proxmox server IPproxmox.node- Proxmox node name (usually "pve")
-
Container Settings:
lxc.vmid- Unique container ID (e.g., 200)lxc.hostname- Container hostname
-
Network:
network.bridge- Network bridge (usually "vmbr0")network.ip_method- Choose "dhcp" or "static"- If static, fill in
ip_address,gateway,nameserver
-
Authentication (choose one):
- Option A: API Token (recommended)
proxmox.api_token_idproxmox.api_token_secret
- Option B: Username/Password
proxmox.usernameproxmox.password
- Option A: API Token (recommended)
Step 3: Run Deployment
Once the configuration file is complete, run:
# The deployment script will be generated based on your config
./deploy-to-proxmox.sh
Configuration Sections Explained
1. Proxmox Host Configuration
This section defines how to connect to your Proxmox server.
Getting API Token (Recommended):
- Log into Proxmox web UI
- Go to Datacenter → Permissions → API Tokens
- Click "Add" to create a new token
- Save the Token ID and Secret
Alternative: Use username/password (less secure)
2. LXC Container Configuration
-
VMID: Must be unique across your Proxmox cluster
- To check used IDs:
pvesh get /cluster/resources --type vm - Typically use 100-999 for containers
- To check used IDs:
-
Template: Available templates
- List available:
pveam available | grep -i ubuntu - Download template:
pveam download local ubuntu-22.04-standard_22.04-1_amd64.tar.zst
- List available:
-
Unprivileged: Recommended for security
true= safer, limited permissionsfalse= full root access (needed for some operations)
3. Resource Allocation
Recommended minimum for this application:
- Memory: 1024 MB (can go up to 2048 MB for better performance)
- Cores: 1-2
- Disk: 8-10 GB
4. Network Configuration
DHCP (Easier):
- Set
ip_method: dhcp - Container gets IP automatically from your router
Static IP (Better for production):
- Set
ip_method: static - Fill in IP address with CIDR notation (e.g., 192.168.1.150/24)
- Set gateway (usually your router IP)
- Set nameserver (DNS server, e.g., 8.8.8.8)
Finding your network settings:
# On Proxmox host
ip addr show vmbr0
ip route | grep default
5. Application Configuration
-
Port 8501: Default Streamlit port
- Can change if needed
- Make sure this port is not in use
-
Git Repository:
- Leave empty to copy files from local directory
- Or provide GitHub/GitLab URL to clone from repository
6. Reverse Proxy & SSL (Optional)
Enable this if you want:
- HTTPS access
- Custom domain name
- Automatic SSL certificates via Let's Encrypt
Requirements:
- Domain name pointing to your Proxmox host
- Port 80 and 443 accessible from internet (for Let's Encrypt)
7. Security & Access
SSH Key (Recommended):
- Generate key:
ssh-keygen -t rsa -b 4096 - Copy your public key:
cat ~/.ssh/id_rsa.pub - Paste into
ssh_public_keyfield
Firewall:
- Set
configure_firewall: trueto restrict access - Specify
allowed_ipsto limit who can access
Deployment Methods
Method 1: Shell Script (Recommended for Beginners)
Simple bash scripts that:
- Create the LXC container
- Install dependencies
- Deploy the application
- Set up systemd service
Pros: Easy to understand and modify Cons: Less sophisticated than IaC tools
Method 2: Terraform
Infrastructure as Code approach:
- Declarative configuration
- State management
- Easy to replicate
Pros: Professional, repeatable, version-controlled Cons: Requires Terraform installation
Method 3: Ansible
Configuration management:
- Powerful automation
- Idempotent operations
- Great for multiple deployments
Pros: Flexible, reusable playbooks Cons: Requires Ansible installation
Example Configurations
Example 1: Simple DHCP Setup
proxmox:
host: "192.168.1.100"
node: "pve"
auth_method: "password"
username: "root@pam"
password: "your-password"
lxc:
vmid: 200
hostname: "qr-generator"
template: "ubuntu-22.04-standard"
network:
bridge: "vmbr0"
ip_method: "dhcp"
automation:
tool: "shell"
Example 2: Production Setup with Static IP
proxmox:
host: "192.168.1.100"
node: "pve"
auth_method: "api_token"
api_token_id: "root@pam!deploy"
api_token_secret: "xxxx-xxxx-xxxx"
lxc:
vmid: 200
hostname: "qr-generator"
template: "ubuntu-22.04-standard"
unprivileged: true
onboot: true
resources:
memory: 2048
cores: 2
disk_size: "10G"
network:
bridge: "vmbr0"
ip_method: "static"
ip_address: "192.168.1.150/24"
gateway: "192.168.1.1"
nameserver: "8.8.8.8"
reverse_proxy:
enabled: true
domain: "qr.example.com"
ssl_enabled: true
ssl_method: "letsencrypt"
letsencrypt_email: "admin@example.com"
security:
ssh_public_key: "ssh-rsa AAAAB3NzaC1yc2E..."
configure_firewall: true
allowed_ips: "192.168.1.0/24"
automation:
tool: "shell"
Troubleshooting
Can't connect to Proxmox API
# Test API connection
curl -k https://YOUR_PROXMOX_IP:8006/api2/json
Container creation fails
- Check VMID is not already in use:
pct list - Verify template exists:
pveam list local - Check storage has space:
pvesm status
Network issues
# Inside container, check network
ip addr show
ip route
ping 8.8.8.8
Application won't start
# SSH into container
ssh root@CONTAINER_IP
# Check service status
systemctl status qr-generator
# Check logs
journalctl -u qr-generator -f
Post-Deployment
Access the Application
-
With DHCP:
- Find IP:
pct exec VMID ip addr show eth0 - Access:
http://CONTAINER_IP:8501
- Find IP:
-
With Static IP:
- Access:
http://YOUR_STATIC_IP:8501
- Access:
-
With Reverse Proxy:
- Access:
https://your-domain.com
- Access:
Manage the Container
# Start container
pct start VMID
# Stop container
pct stop VMID
# Enter container console
pct enter VMID
# Check container status
pct status VMID
# View container config
pct config VMID
Manage the Application
# Inside container
systemctl status qr-generator # Check status
systemctl restart qr-generator # Restart app
systemctl stop qr-generator # Stop app
systemctl start qr-generator # Start app
journalctl -u qr-generator -f # View logs
Next Steps
- Fill out the configuration file
- Let me know when ready, and I'll generate the deployment scripts
- Review and run the deployment
- Access your QR code generator!
Support
If you encounter any issues:
- Check the logs (see Troubleshooting section)
- Verify all configuration values are correct
- Ensure Proxmox has necessary permissions and resources
- Ask for help with specific error messages