Skip to content

Provision the Six VMs

First PublishedLast UpdatedByAtif Alam

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.

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.

Terminal window
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_rsa
qm create 9000 --memory 2048 --cores 2 --name ubuntu-2404-a --net0 virtio,bridge=vmbr0
qm importdisk 9000 noble-server-cloudimg-amd64.img local-zfs
qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-zfs:vm-9000-disk-0
qm set 9000 --ide2 local-zfs:cloudinit
qm set 9000 --boot c --bootdisk scsi0
qm set 9000 --serial0 socket --vga serial0
qm set 9000 --ciuser ubuntu --sshkeys /root/.ssh/id_rsa.pub
qm template 9000

On Host B, run the same commands with VMID 9001 and --name ubuntu-2404-b. qm importdisk and --scsi0 then use vm-9001-disk-0.

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.

VMVMIDTemplateDisk
cp11019000 on Host A60 GB
worker-11029000 on Host A150 GB
worker-21039000 on Host A150 GB
cp21119001 on Host B60 GB
worker-31129001 on Host B150 GB
worker-41139001 on Host B150 GB

Example for cp1 on Host A. <DNS-IP> is your resolver, often the same address as the gateway.

Terminal window
qm clone 9000 101 --name cp1 --full
qm set 101 --memory 4096 --balloon 0 --cores 2
qm resize 101 scsi0 60G
qm set 101 --ipconfig0 ip=<CP1-IP>/24,gw=<GATEWAY-IP> --nameserver <DNS-IP>
qm start 101

Repeat 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:

Terminal window
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.

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.

Terminal window
sudo apt update
Terminal window
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe overlay br_netfilter
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sudo sysctl --system
Terminal window
sudo swapoff -a
sudo sed -i '/ swap / s/^/#/' /etc/fstab
sudo apt install -y chrony && sudo systemctl enable --now chrony

Installing chrony replaces Ubuntu’s systemd-timesyncd. One time service should be running.

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.

Terminal window
sudo apt install -y containerd
sudo mkdir -p /etc/containerd/conf.d
containerd config default | sudo tee /etc/containerd/config.toml >/dev/null
if grep -q 'SystemdCgroup = false' /etc/containerd/config.toml; then
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
else
sudo tee /etc/containerd/conf.d/k8s.toml >/dev/null <<'EOF'
[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runc.options]
SystemdCgroup = true
EOF
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
fi
fi
grep -n 'SystemdCgroup' /etc/containerd/config.toml /etc/containerd/conf.d/*.toml
sudo systemctl restart containerd && sudo systemctl enable containerd

grep 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)”
Terminal window
sudo apt install -y apt-transport-https ca-certificates curl gpg
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.33/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo '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.list
sudo apt update
sudo apt install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

Write 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.

Terminal window
echo 'KUBELET_EXTRA_ARGS="--resolv-conf=/run/systemd/resolve/resolv.conf"' | sudo tee /etc/default/kubelet
sudo systemctl restart kubelet

The restart is harmless when kubelet is not active yet. The file is in place before kubeadm init and kubeadm join on the next pages.

On the four worker VMs (needed later by the Longhorn page):

Terminal window
sudo apt install -y open-iscsi nfs-common
sudo systemctl enable --now iscsid

On each Proxmox host, qm list shows that host’s three VMs running. From that host:

Terminal window
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.

Next: External etcd and kubeadm Bootstrap.