Prepare Ubuntu VM Template with cloud-init for vSphere

Prepare Ubuntu VM Template with cloud-init for vSphere

Introduction

Purpose

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

Objectives

Create Ubuntu VM Template with cloud-init for vSphere

Prerequisites

  1. vSphere 6.5 or 6.7
  2. govc
  3. curl or wget

Procedure

To download Ubuntu OVA template, you can click here.

  1. Download ova template:
wget https://cloud-images.ubuntu.com/releases/18.04/release/ubuntu-18.04-server-cloudimg-amd64.ova -O ubuntu-18.04-cloud-init.ova
# or
curl -L https://cloud-images.ubuntu.com/releases/18.04/release/ubuntu-18.04-server-cloudimg-amd64.ova --output ubuntu-18.04-cloud-init.ova
  1. Set environment variables for govc (docs). Use the following commands as an example:
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
  1. Upload ova image to vCenter:
govc import.ova --name="ubuntu-18.04-cloud-init" ubuntu-18.04-cloud-init.ova
  1. Open vSphere WebUI

    1. Disable vApp for this VM. (VM -> Configure (Tab) -> Settings -> vApp Options -> Edit -> Enable vApp options -> Ok)
    2. Increase the boot disk size to 40 GB or more. Default size of 10Gb is too small. (Optional: you can increase the boot disk when you create the k8s cluster)
  2. Convert VM to VM Template.

govc vm.markastemplate ubuntu-18.04-cloud-init