Provision the Six VMs
Second page of the HA Kubernetes on Two Proxmox Hosts series. The Proxmox cluster is already quorate. This page builds the six Ubuntu guests and prepares each one for kubeadm.
Paste the commands below, or run the node-prep tag from Automate the Cluster. Both end at the same checks. Terraform also creates the template and the clones.
Host A gets cp1 and two workers. Host B gets cp2 and two workers. Sizes and addresses are on the hub network plan and VM table. Do this whole page on each Proxmox host. VMIDs are unique across the cluster, so Host B cannot reuse Host A’s numbers. A template disk on Host A is not on Host B.
Step 1: Create the Template
Section titled “Step 1: Create the Template”These commands turn the Ubuntu 24.04 cloud image into a Proxmox template. The file is qcow2 even though the name ends in .img. qm create makes an empty VM. qm importdisk copies the image onto local-zfs. The qm set lines attach that disk as the SCSI boot disk, add a cloud-init drive, and send the console to the serial port so noVNC shows the boot. qm template freezes the VM. On an LVM-thin host, substitute local-lvm for local-zfs in the commands below.
Host A uses VMID 9000, named ubuntu-2404-a. Host B uses VMID 9001, named ubuntu-2404-b. Cloud-init runs on a clone’s first boot, not on the template. Do not start either template.
On each Proxmox host, generate a root key when that host does not already have one. Host B does not have Host A’s key. The image has no root password and no password login. The ubuntu user gets this host’s public key, and every clone inherits it.
wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img[ -f /root/.ssh/id_rsa.pub ] || ssh-keygen -t rsa -b 4096 -N '' -f /root/.ssh/id_rsaqm create 9000 --memory 2048 --cores 2 --name ubuntu-2404-a --net0 virtio,bridge=vmbr0qm importdisk 9000 noble-server-cloudimg-amd64.img local-zfsqm set 9000 --scsihw virtio-scsi-pci --scsi0 local-zfs:vm-9000-disk-0qm set 9000 --ide2 local-zfs:cloudinitqm set 9000 --boot c --bootdisk scsi0qm set 9000 --serial0 socket --vga serial0qm set 9000 --ciuser ubuntu --sshkeys /root/.ssh/id_rsa.pubqm template 9000On Host B, run the same commands with VMID 9001 and --name ubuntu-2404-b. qm importdisk and --scsi0 then use vm-9001-disk-0.
Step 2: Clone per VM
Section titled “Step 2: Clone per VM”qm clone copies that host’s template into a VM with its own disk. qm resize grows the Proxmox disk. Cloud-init growpart grows the filesystem inside the guest on first boot. --ipconfig0 sets the static address. --nameserver is required with that static address: without a resolver, apt on the guest cannot look up package hosts. The VM name becomes the guest hostname, which kubeadm later uses as the node name.
| VM | VMID | Template | Disk |
|---|---|---|---|
| cp1 | 101 | 9000 on Host A | 60 GB |
| worker-1 | 102 | 9000 on Host A | 150 GB |
| worker-2 | 103 | 9000 on Host A | 150 GB |
| cp2 | 111 | 9001 on Host B | 60 GB |
| worker-3 | 112 | 9001 on Host B | 150 GB |
| worker-4 | 113 | 9001 on Host B | 150 GB |
Example for cp1 on Host A. <DNS-IP> is your resolver, often the same address as the gateway.
qm clone 9000 101 --name cp1 --fullqm set 101 --memory 4096 --balloon 0 --cores 2qm resize 101 scsi0 60Gqm set 101 --ipconfig0 ip=<CP1-IP>/24,gw=<GATEWAY-IP> --nameserver <DNS-IP>qm start 101Repeat for the other five VMs with the IDs in the table. Host B clones template 9001. Workers use qm resize ... 150G.
From that same Proxmox host, after the clone finishes its first boot:
ssh ubuntu@<CP1-IP>Set —balloon 0 on every VM: no memory ballooning or overcommit. Keep ~4 GB free for the Proxmox host itself; if a host shows memory pressure later, trim worker VMs to 3.5 GB instead of squeezing the hypervisor.
Pin the VMs to their hosts. Do not live-migrate or configure Proxmox HA failover for the control-plane/etcd VMs — the quorum design depends on etcd1 and etcd2 staying on separate physical machines. Migrating cp1 to Host B would put two etcd members on one host and defeat the failure model.
Step 3: Node Prep on All Six VMs
Section titled “Step 3: Node Prep on All Six VMs”SSH in as ubuntu and run this on every VM. Versions come from the hub’s version matrix. Start by refreshing the package lists. A fresh cloud image often has indexes that are too old for the next installs.
sudo apt updateKernel Modules and Sysctl
Section titled “Kernel Modules and Sysctl”cat <<EOF | sudo tee /etc/modules-load.d/k8s.confoverlaybr_netfilterEOFsudo modprobe overlay br_netfilter
cat <<EOF | sudo tee /etc/sysctl.d/k8s.confnet.ipv4.ip_forward = 1net.bridge.bridge-nf-call-iptables = 1EOFsudo sysctl --systemSwap Off and Time Sync
Section titled “Swap Off and Time Sync”sudo swapoff -asudo sed -i '/ swap / s/^/#/' /etc/fstabsudo apt install -y chrony && sudo systemctl enable --now chronyInstalling chrony replaces Ubuntu’s systemd-timesyncd. One time service should be running.
containerd
Section titled “containerd”Ubuntu 24.04 installs containerd 2.2. Its default config often has no SystemdCgroup = false line, so a blind substitution changes nothing and kubelet later fights cgroupfs. Replace the line when it is present. Otherwise add the containerd 2.x setting in a drop-in and import that file.
sudo apt install -y containerdsudo mkdir -p /etc/containerd/conf.dcontainerd config default | sudo tee /etc/containerd/config.toml >/dev/nullif grep -q 'SystemdCgroup = false' /etc/containerd/config.toml; then sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.tomlelse sudo tee /etc/containerd/conf.d/k8s.toml >/dev/null <<'EOF'[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runc.options] SystemdCgroup = trueEOF if grep -q '^imports = ' /etc/containerd/config.toml; then sudo sed -i 's|^imports = .*|imports = ["/etc/containerd/conf.d/*.toml"]|' /etc/containerd/config.toml else sudo sed -i '1a imports = ["/etc/containerd/conf.d/*.toml"]' /etc/containerd/config.toml fifigrep -n 'SystemdCgroup' /etc/containerd/config.toml /etc/containerd/conf.d/*.tomlsudo systemctl restart containerd && sudo systemctl enable containerdgrep must show SystemdCgroup = true.
SystemdCgroup = true is required — kubelet defaults to the systemd cgroup driver, and a mismatch causes pods to restart in loops.
kubeadm, kubelet, kubectl (Pinned and Held)
Section titled “kubeadm, kubelet, kubectl (Pinned and Held)”sudo apt install -y apt-transport-https ca-certificates curl gpgcurl -fsSL https://pkgs.k8s.io/core:/stable:/v1.33/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpgecho 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.33/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.listsudo apt updatesudo apt install -y kubelet kubeadm kubectlsudo apt-mark hold kubelet kubeadm kubectlWrite the kubelet resolver after that install. The package ships /etc/default/kubelet, and writing the file first lets the package replace it. Ubuntu uses systemd-resolved. Kubelet must read the host resolver, not the stub at /etc/resolv.conf.
echo 'KUBELET_EXTRA_ARGS="--resolv-conf=/run/systemd/resolve/resolv.conf"' | sudo tee /etc/default/kubeletsudo systemctl restart kubeletThe restart is harmless when kubelet is not active yet. The file is in place before kubeadm init and kubeadm join on the next pages.
Longhorn Prerequisites (Workers)
Section titled “Longhorn Prerequisites (Workers)”On the four worker VMs (needed later by the Longhorn page):
sudo apt install -y open-iscsi nfs-commonsudo systemctl enable --now iscsidVerify Before Moving On
Section titled “Verify Before Moving On”On each Proxmox host, qm list shows that host’s three VMs running. From that host:
ssh ubuntu@<vm-ip> 'systemctl is-active containerd && kubeadm version -o short && free -h | grep -i swap'Expected: containerd active, kubeadm at the pinned version, swap showing 0B.