Quick overview on how to prepare CentOS-7 VM Template with cloud-init for vSphere.
Create CentOS-7 VM Template with cloud-init for vSphere
To download CentOS-7 image in qcow2 format, you can click here.
wget https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2
# or
curl -L https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2
qemu-img convert -O vmdk -o subformat=streamOptimized "CentOS-7-x86_64-GenericCloud.qcow2" "centos-7-cloud-init.vmdk"
export GOVC_URL="vcenter.example.com"
export GOVC_USERNAME="username@example.com"
export GOVC_PASSWORD='password'
export GOVC_INSECURE="true"
export GOVC_DATACENTER="DC1"
export GOVC_DATASTORE="/DC1/datastore/data_store1"
export GOVC_RESOURCE_POOL="/DC1/host/192.168.3.2/Resources"
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
govc import.vmdk "centos-7-cloud-init.vmdk"
govc datastore.disk.inflate "centos-7-cloud-init/centos-7-cloud-init.vmdk"
Create a new virtual machine using that image with vSphere WebUI.
During the Customize Hardware step:
ADD NEW DEVICE
, select Existing Hard Disk
and select the disk previously created.Increase the boot disk size to 40 GB or more. Default size of 8Gb is too small. (Optional: you can increase the boot disk when you create the k8s cluster)
Convert VM to VM Template.
govc vm.markastemplate ${VM_NAME}
Advanced Options
and set Network Interface
to eth0
for each node group (including master) using this image.