Andrew Mercer
on this page

This is the "Kubernetes on VMs on Kubernetes" pattern, and it's the main reason to pair Harvester with Rancher.

20.1 Provisioning flow

  1. Rancher → Cluster Management → Cloud Credentials → create a Harvester credential (select the imported Harvester cluster; Rancher generates a scoped kubeconfig).
  2. Create cluster → Harvester (RKE2 or K3s).
  3. Define machine pools: CPU, memory, disk size, image (e.g. a cloud image), VM network, namespace on Harvester, user data.
  4. Choose the Harvester cloud provider — Rancher wires up: - harvester-cloud-provider (CCM): node lifecycle and LoadBalancer Services via Harvester LB. - harvester-csi-driver: PVCs in the guest cluster are backed by Longhorn volumes on the host Harvester cluster ("hot-plugged" into the guest VMs).
  5. Rancher creates the VMs via the Harvester node driver, bootstraps RKE2/K3s, and the cluster appears in Rancher.

20.2 Guest-cluster storage

# In the guest cluster
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: harvester-nvme
provisioner: driver.harvesterhci.io
allowVolumeExpansion: true
parameters:
  hostStorageClass: nvme-2rep     # a StorageClass on the Harvester host
  • Default StorageClass in guest clusters: harvester.
  • RWO block/filesystem volumes are hot-plugged as disks into the guest VM.
  • RWX for guest clusters arrived in recent releases (served through Longhorn's share-manager/NFS path) — check version notes.
  • Volume snapshots are supported when configured with the matching VolumeSnapshotClass.

20.3 Guest-cluster load balancers

apiVersion: v1
kind: Service
metadata:
  name: ingress
  annotations:
    cloudprovider.harvesterhci.io/ipam: pool      # or dhcp
spec:
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: ingress-nginx
  ports:
    - name: https
      port: 443
      targetPort: 443

The Harvester LB allocates a VIP on the VM network and forwards to guest node ports. For many services, consider running MetalLB or kube-vip inside the guest cluster instead, or put one LB in front of your ingress controller.

20.4 Machine pool design

Pool Sizing (example) Notes
cp 3 × 4 vCPU / 8 GiB / 60 GiB etcd + control plane; anti-affinity across Harvester hosts
workers N × 8 vCPU / 32 GiB / 100 GiB Scale out; enable autoscaling where supported
gpu 1–2 × with vGPU Uses PCI/vGPU passthrough; no live migration

Use the cluster autoscaler integration for Rancher-provisioned machine pools if your Rancher version supports it.

20.5 Alternative: Cluster API

Via Rancher Turtles and the CAPHV (Cluster API Provider Harvester) project you can provision guest clusters with pure CAPI manifests — better if you already standardize on CAPI.


← Harvester + Rancher integration · Index · Infrastructure as code →