Prepare CentOS-8 VM Template with cloud-init for vSphere

Prepare CentOS-8 VM Template with cloud-init for vSphere



Quick overview on how to prepare CentOS-8 VM Template with cloud-init for vSphere.


Create CentOS-8 VM Template with cloud-init for vSphere


  1. vSphere 6.5 or 6.7
  2. govc
  3. curl or wget
  4. qemu-img


CentOS-8 image in qcow2 format can be found here. Use one of the GenericCloud image links.

  1. Download CentOS images in qcow2 format:
# or
curl -L
  1. Convert it to vmdk e.g.
qemu-img convert -O vmdk -o subformat=streamOptimized "CentOS-8-GenericCloud-8.2.2004-20200611.2.x86_64.qcow2" "centos-8-cloud-init.vmdk"
  1. Set environment variables for govc (docs). Use the following commands as an example:
export GOVC_URL=""
export GOVC_PASSWORD='password'
export GOVC_INSECURE="true"
export GOVC_DATASTORE="/DC1/datastore/data_store1"
export GOVC_RESOURCE_POOL="/DC1/host/"
export GOVC_FOLDER="/DC1/vm/templates"

# useful commands
# show available pools
govc find / -type p
# show available folders
govc find / -type f
# show available datastores
govc find / -type s
  1. Upload vmdk disk to vSphere using GOVC:
govc import.vmdk "centos-8-cloud-init.vmdk"
  1. (Optional) Inflate the created disk (see vmware documentation for more details)
govc datastore.disk.inflate "centos-8-cloud-init/centos-8-cloud-init.vmdk"
  1. Create a new virtual machine using that image with vSphere WebUI. Pay attention:

    1. The boot disk should be on the SATA controller, because the GenericCloud image of CentOS-8 doesn’t have default SCSI driver.
    2. Kublr uses terraform to create a VM in vSphere, but terraform cannot manage SATA disks because it only supports SCSI. Therefore, for this VM Template, we must use a dummy disk on the SCSI controller.
  2. During the Customize Hardware step:

    1. Remove the disk present by default
    2. Click on ADD NEW DEVICE, select Existing Hard Disk and select the disk previously created. Select SATA controller for this disk
    3. Click on ADD NEW DEVICE, select Hard Disk, set 1 GB of size. Use SCSI controller for this disk. Kublr is not going to use this disk for data, so you can set Disk Provisioning to Thin Provision.
  3. Increase the boot disk size to 40 GB or more. Default size of 10Gb is too small. You cannot increase the boot disk when creating a k8s cluster, because it is installed on the SATA controller

  4. Convert VM to VM Template.

govc vm.markastemplate ${VM_NAME}
  1. When creating a cluster with this image, open Advanced Options and set Network Interface to eth0 for each node group (including master) using this image.

  2. CentOS 8 is only supported as a technical preview, and you can use this OS only with agent versions: 1.17.3, 1.17.4, 1.17.7. And don’t forget to set to cni-calico and disable the node local dns component by setting to false. Read about it in our release notes.