packer-kubernetes-debian is a set of configuration files used to build an automated Debian 12 virtual machine images using Packer.
This repository was forked from https://github.com/eaksel/packer-Debian11 and heavily modified:
- Uses Debian cloud images instead of an installation iso file
- Uses cloud-init instead of ansible
The image is created with everything required to use the provided VM as a Kubernetes node.
- Packer
- A working Qemu installation with the kvm accellerator.
Commands to create an automated VM image:
To create a Debian VM image use the following command:
packer build debian.pkr.hcl
By default the vm is based on daily cloud images from Debian. The latest daily image is configured. This can be changed in the variables section in debian.pkr.hcl
.
The Kubernetes version installed for kubectl
, kubeadm
, and kubelet
is also configurable in the variable section in debian.pkr.hcl
.
There are no default credentials for the default debian
user. Use cloud-init to provide an ssh authorized key to be able to log in.
Create a template VM that can be cloned to create actual VMs.
- Create a VM without any storage
qm create $VMID -name kubetemplate -agent enabled=1 \ -sockets 2 -cores 2 -cpu host -memory 4096 \ -net0 model=virtio,bridge=vmbr0 \ -scsihw virtio-scsi-single \ -ostype l26 -serial0 socket \ -rng0 source=/dev/hwrng
- Copy to built image (
$IMAGE
) to one of the Proxmox cluster nodes - Import the image into Proxmox and assign it as a disk to the target VM
qm disk import $VMID $IMAGE $STORAGE_NAME
- Update the VM to attach the newly imported disk to the correct hardware. Virtio works best, but SATA or SCSI are also fine.
qm set $VMID -virtio0 $STORAGE_NAME:vm-$VMID-disk-0
- Add cloud-init to the vm
qm set $VMID --ide2 $STORAGE_NAME:cloudinit
- Update the VM's boot order
qm set $VMID -boot 'order=virtio0;net0'
- Transform the new VM into a template VM
qm template $VMID
This template can be cloned to create a runnable VM. Use cloudinit
to set the new VM's network information and an SSH key for the default debian
user.