Skip to content

VirtualMachineTemplate

VirtualMachineTemplate is a Kubernetes Custom Resource Definition (CRD) that defines a template for a VirtualMachine. It is used to create a VirtualMachine object and then converts that into a template for future use. It utilizes the 'CloudInit' behind the scenes to configure the VirtualMachine. VirtualMachineTemplate has three main specs that you can define:

  • cloudInitConfig: This struct includes cloud-init configuration that will be used to configure the VirtualMachine. This field is mandatory to create a VirtualMachineTemplate.

  • imageConfig: This struct includes the image configuration that will be used to create the VirtualMachine from the template. You should use cloud-init compatible images within this field.

  • virtualMachineConfig: This struct includes the VirtualMachine configuration that will be used to create the VirtualMachine from the template. You can define the VirtualMachine configuration like cores, memory, disk, network, etc. within this field. This is non-mandatory struct and default values will be used if not defined.

Creating VirtualMachineTemplate

To create a new VirtualMachineTemplate in Proxmox, you need to create a VirtualMachineTemplate object. This object should be generated by other VirtualMachineTemplate objects.

apiVersion: proxmox.alperen.cloud/v1alpha1
kind: VirtualMachineTemplate
metadata:
  name: virtualmachinetemplate-sample
spec:
  name: virtualmachinetemplate-sample
  node: lowtower
  cloudInitConfig:
    ipConfig:
      cidr: "24"
      gateway: 10.153.0.1
      ip: 10.153.0.99
    password: ubuntu
    upgradePackages: true
    user: ubuntu 
  imageConfig:
    content: iso
    filename: bionic-server-cloudimg-amd64.img
    node: lowtower
    storage: local
    url: https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
  virtualMachineConfig:
    cores: 2
    memory: 2048
    network:
      bridge: vmbr0
      model: virtio
    sockets: 1