Cluster Bootstrap
This guide provides a comprehensive walkthrough for bootstrapping a production-ready PiVirt cluster from bare metal or virtual machines, covering node initialization, control plane formation, and worker joins.
Prerequisites
Section titled “Prerequisites”Hardware Requirements
Section titled “Hardware Requirements”- Control Plane Nodes: Minimum 3 nodes (for HA)
- 4 CPU cores
- 8 GB RAM
- 50 GB disk
- Worker Nodes: As needed
- 8+ CPU cores
- 16+ GB RAM
- 200+ GB disk
- Network: 1 Gbps+ connectivity between nodes
- Storage: Shared storage (iSCSI/NFS) or local storage per node
Software Requirements
Section titled “Software Requirements”- Linux kernel 5.10+
- KVM support enabled
- NTP synchronized
- SSH access between nodes
Step 1: Prepare Nodes
Section titled “Step 1: Prepare Nodes”Install Base System
Section titled “Install Base System”# On all nodesapt-get update && apt-get upgrade -y
# Install required packagesapt-get install -y \ qemu-kvm \ bridge-utils \ open-iscsi \ multipath-tools \ ntp \ curl \ wgetEnable KVM
Section titled “Enable KVM”# Load KVM modulesmodprobe kvm_intel # or kvm_amdmodprobe vhost_net
# Make persistentcat >> /etc/modules-load.d/kvm.conf <<EOFkvm_intelvhost_netEOF
# Verify KVMkvm-okConfigure Networking
Section titled “Configure Networking”# Create bridgecat > /etc/netplan/01-bridge.yaml <<EOFnetwork: version: 2 bridges: virbr0: interfaces: [eth0] dhcp4: yesEOF
netplan applyStep 2: Initialize First Control Plane Node
Section titled “Step 2: Initialize First Control Plane Node”Install PiVirt Components
Section titled “Install PiVirt Components”# Download and install pivirtdcurl -L https://github.com/pilab-dev/pivirt/releases/latest/download/pivirtd-linux-amd64 -o /usr/local/bin/pivirtdchmod +x /usr/local/bin/pivirtd
# Download and install agentcurl -L https://github.com/pilab-dev/pivirt/releases/latest/download/pivirt-agent-linux-amd64 -o /usr/local/bin/pivirt-agentchmod +x /usr/local/bin/pivirt-agent
# Download and install pvclicurl -L https://github.com/pilab-dev/pivirt/releases/latest/download/pvcli-linux-amd64 -o /usr/local/bin/pvclichmod +x /usr/local/bin/pvcliInitialize Cluster
Section titled “Initialize Cluster”# Initialize clusterpvcli cluster init --name prod-cluster \ --control-plane 3 \ --etcd-members 3
# Verify clusterpvcli cluster get prod-clusterConfigure Storage
Section titled “Configure Storage”# Create storage poolpvcli storage pool create \ --name default \ --type dir \ --path /var/lib/pivirtd/images
# Or use LVMpvcli storage pool create \ --name default \ --type lvm \ --volume-group pivirtd-vgStep 3: Join Additional Control Plane Nodes
Section titled “Step 3: Join Additional Control Plane Nodes”Generate Join Token
Section titled “Generate Join Token”# On first control plane nodepvcli cluster token create --ttl 24h# Output: Join token: abc123...Join Nodes
Section titled “Join Nodes”# On each additional control plane nodepvcli cluster join \ --token abc123... \ --node-ip 10.0.1.11 \ --role control-plane
# Verifypvcli cluster node listStep 4: Join Worker Nodes
Section titled “Step 4: Join Worker Nodes”Join Workers
Section titled “Join Workers”# On each worker nodepvcli cluster join \ --token abc123... \ --node-ip 10.0.1.20 \ --role worker
# Verifypvcli cluster node listStep 5: Configure Shared Storage
Section titled “Step 5: Configure Shared Storage”iSCSI Setup
Section titled “iSCSI Setup”# On storage nodepvcli storage target create \ --iqn iqn.2024-01.hu.pilab:vm-storage \ --alias "VM Storage"
# On all nodespvcli storage initiator discover --portal 10.0.1.10:3260pvcli storage initiator login \ --target iqn.2024-01.hu.pilab:vm-storage \ --portal 10.0.1.10:3260OCFS2 Setup
Section titled “OCFS2 Setup”# Format OCFS2 volumepvcli storage ocfs2 create \ --name vm-shared \ --device /dev/disk/by-id/scsi-360050764008181c60000000000000001 \ --cluster pivirt-cluster
# Mount on all nodespvcli storage ocfs2 mount \ --name vm-shared \ --all-nodesStep 6: Configure Networking
Section titled “Step 6: Configure Networking”Create VXLAN Network
Section titled “Create VXLAN Network”pvcli network create \ --name vxlan-net \ --type vxlan \ --vni 1000 \ --local-ip 10.0.1.10 \ --remote-ips 10.0.1.11,10.0.1.12Step 7: Verify Cluster
Section titled “Step 7: Verify Cluster”Check Cluster Health
Section titled “Check Cluster Health”# Check cluster statuspvcli cluster get prod-cluster -o yaml
# Check node statuspvcli cluster node list
# Check component healthpvcli cluster healthCreate Test VM
Section titled “Create Test VM”# Create test VMpvcli vm create --name test-vm \ --image ubuntu-24.04 \ --cpu 1 \ --memory 1Gi \ --disk 10Gi
# Start VMpvcli vm start test-vm
# Verify VMpvcli vm get test-vmStep 8: Configure Monitoring
Section titled “Step 8: Configure Monitoring”Install Prometheus
Section titled “Install Prometheus”# Deploy Prometheuskubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/bundle.yamlConfigure Alerting
Section titled “Configure Alerting”groups: - name: pivirt.rules rules: - alert: PivirtNodeDown expr: pivirt_cluster_node_count{status="ready"} < 3 for: 5m labels: severity: criticalPost-Bootstrap Tasks
Section titled “Post-Bootstrap Tasks”1. Configure Backup
Section titled “1. Configure Backup”# Setup etcd backuppvcli cluster backup create --name initial-backup2. Configure RBAC
Section titled “2. Configure RBAC”# Create admin userpvcli auth user create \ --email admin@pilab.hu \ --role admin
# Create operator userpvcli auth user create \ --email operator@pilab.hu \ --role operator3. Configure TLS
Section titled “3. Configure TLS”# Generate certificatespvcli cert generate --cn agent.pilab.hu
# Distribute certificatesscp ca.crt node-02:/etc/pivirt-agent/tls/scp ca.crt node-03:/etc/pivirt-agent/tls/Troubleshooting
Section titled “Troubleshooting”Node Won’t Join
Section titled “Node Won’t Join”# Check network connectivityping 10.0.1.10
# Check token validitypvcli cluster token verify <token>
# Check logsjournalctl -u pivirt-agent -fetcd Quorum Lost
Section titled “etcd Quorum Lost”# Check etcd statusetcdctl endpoint health
# Restore from backuppvcli cluster backup restore --name initial-backupStorage Not Accessible
Section titled “Storage Not Accessible”# Check iSCSI sessionsiscsiadm -m session -P3
# Check multipathmultipath -ll