# create a new VM with VirtIO SCSI controller
qm create 9000 --memory 2048 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci
# import the downloaded disk to the local-lvm storage, attaching it as a SCSI drive
qm set 9000 --scsi0 local-lvm:0,import-from=/var/lib/vz/template/iso/jammy-server-cloudimg-amd64.img
qm disk resize 9000 scsi0 100G
qm set 9000 --ide2 local-lvm:cloudinit
qm set 9000 --boot order=scsi0
qm set 9000 --serial0 socket --vga serial0
qm template 9000
git clone <https://github.com/dave-andrew/k8s-terraform>
cd k8s-terraform
touch credentials.auto.tfvars && touch cluster.auto.tfvars
# credentials.auto.tfvars
proxmox_api_url = "(proxmox api server url)"
proxmox_api_token_id = "(token id)"
proxmox_api_token_secret = "(token secret)"
ciuser = "(user)"
cipassword = "(pass)"
sshkeys = "(secrets)"
Set the variables from the configuration below as your like:
# cluster.auto.tfvars
control-planes = {
"control-plane-1" = {
vmid = '100'
name = 'control-planes-1'
desc = 'control-planes-1'
target_node = 'SERVER-1'
ipconfig0 = 'ip=10.35.10.20/24,gw=10.35.10.1'
nameserver = "1.1.1.1, 8.8.8.8"
memory = 32768
}
"control-plane-2" = {
vmid = '101'
name = 'control-planes-2'
desc = 'control-planes-2'
target_node = 'SERVER-1'
ipconfig0 = 'ip=10.35.10.21/24,gw=10.35.10.1'
nameserver = "1.1.1.1, 8.8.8.8"
memory = 32768
}
}
workers = {
"worker-1" = {
vmid = '102'
name = 'worker-1'
desc = 'worker-1'
target_node = 'SERVER-1'
ipconfig0 = 'ip=10.35.10.22/24,gw=10.35.10.1'
nameserver = "1.1.1.1, 8.8.8.8"
memory = 32768
}
"worker-2" = {
vmid = '103'
name = 'worker-2'
desc = 'worker-2'
target_node = 'SERVER-1'
ipconfig0 = 'ip=10.35.10.23/24,gw=10.35.10.1'
nameserver = "1.1.1.1, 8.8.8.8"
memory = 32768
}
}
<aside> 💡
Make sure the VM’s have static IP Address or a reserved DHCP IP Address to prevent changes in IP Address that would disrupt the Kubernetes Cluster.
</aside>
terraform init
terraform apply