Kubernetes Workload Installation
Deploy PiVirt into existing Kubernetes clusters using the official Helm charts or operator manifests to manage hypervisor nodes declaratively.
Prerequisites
Section titled “Prerequisites”- Kubernetes 1.28+
- kubectl configured
- Helm 3.x (optional)
- Nodes with KVM support
Installation Methods
Section titled “Installation Methods”Method 1: Helm (Recommended)
Section titled “Method 1: Helm (Recommended)”# Add PiVirt Helm repositoryhelm repo add pivirt https://charts.pilab.huhelm repo update
# Install PiVirt operatorhelm install pivirt pivirt/pivirt-operator \ --namespace pivirt-system \ --create-namespace \ --set operator.replicas=3
# Verify installationkubectl get pods -n pivirt-systemMethod 2: kubectl
Section titled “Method 2: kubectl”# Install CRDskubectl apply -f https://github.com/pilab-dev/pivirt/releases/latest/download/crds.yaml
# Install operatorkubectl apply -f https://github.com/pilab-dev/pivirt/releases/latest/download/operator.yaml
# Verify installationkubectl get pods -n pivirt-systemCreate a PiVirt Cluster
Section titled “Create a PiVirt Cluster”apiVersion: pivirt.pilab.hu/v1kind: PiVirtClustermetadata: name: production namespace: pivirt-systemspec: version: "v0.0.89"
# Control plane controlPlane: replicas: 3 resources: requests: cpu: "2" memory: "4Gi" limits: cpu: "4" memory: "8Gi" storage: size: "50Gi" storageClass: "standard"
# Workers workers: replicas: 5 resources: requests: cpu: "8" memory: "16Gi" limits: cpu: "16" memory: "32Gi" storage: size: "200Gi" storageClass: "standard"
# Networking networking: serviceType: LoadBalancer externalTrafficPolicy: Local
# Storage storage: defaultPool: type: "lvm" volumeGroup: "pivirtd-vg" thinPool: "pivirtd-thin"
# Security security: tls: enabled: true pitrust: enabled: true operator: true rbac: enabled: true# Apply clusterkubectl apply -f cluster.yaml
# Wait for cluster to be readykubectl wait --for=condition=Ready pivirtcluster/production -n pivirt-system --timeout=600s
# Check cluster statuskubectl get pivirtcluster production -n pivirt-system -o yamlConfiguration
Section titled “Configuration”High Availability
Section titled “High Availability”spec: controlPlane: replicas: 3 # Minimum 3 for HA antiAffinity: true # Spread across nodes podDisruptionBudget: minAvailable: 2Storage Configuration
Section titled “Storage Configuration”spec: storage: defaultPool: type: "lvm" volumeGroup: "pivirtd-vg" thinPool: "pivirtd-thin"
additionalPools: - name: "fast-pool" type: "iscsi" targetIQN: "iqn.2024-01.hu.pilab:storage" portal: "10.0.1.10:3260"Monitoring
Section titled “Monitoring”spec: monitoring: enabled: true prometheus: serviceMonitor: true rules: true grafana: dashboards: trueAccessing the Cluster
Section titled “Accessing the Cluster”Get Credentials
Section titled “Get Credentials”# Get admin tokenkubectl get secret pivirt-admin-token -n pivirt-system -o jsonpath='{.data.token}' | base64 -d
# Get CA certificatekubectl get secret pivirt-ca-cert -n pivirt-system -o jsonpath='{.data.ca\.crt}' | base64 -d > ca.crtConfigure pvcli
Section titled “Configure pvcli”# Get cluster endpointENDPOINT=$(kubectl get service pivirt-agent -n pivirt-system -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
# Configure pvclipvcli config set-context production \ --endpoint $ENDPOINT:8443 \ --ca-file ca.crt \ --token $(kubectl get secret pivirt-admin-token -n pivirt-system -o jsonpath='{.data.token}' | base64 -d)
pvcli config use-context productionUpgrading
Section titled “Upgrading”# Upgrade operatorhelm upgrade pivirt pivirt/pivirt-operator \ --namespace pivirt-system \ --set operator.replicas=3
# Upgrade clusterkubectl patch pivirtcluster production -n pivirt-system \ --type='merge' \ -p '{"spec":{"version":"v0.0.90"}}'
# Monitor upgradekubectl get pivirtcluster production -n pivirt-system -wUninstalling
Section titled “Uninstalling”# Delete clusterkubectl delete pivirtcluster production -n pivirt-system
# Uninstall operatorhelm uninstall pivirt -n pivirt-system
# Delete CRDskubectl delete -f https://github.com/pilab-dev/pivirt/releases/latest/download/crds.yaml
# Delete namespacekubectl delete namespace pivirt-systemTroubleshooting
Section titled “Troubleshooting”Check operator logs
Section titled “Check operator logs”kubectl logs -n pivirt-system deployment/pivirt-operator -fCheck cluster status
Section titled “Check cluster status”kubectl describe pivirtcluster production -n pivirt-systemCheck pod status
Section titled “Check pod status”kubectl get pods -n pivirt-system -o wide