How to deploy Ubuntu cloud images to Nutanix AHV

In this example we use the KVM cloud image from the Canonical Ubuntu image repository. More information on Ubuntu cloud images is on the canonical cloud image page. More detail on the cloud image boot process and cloud-init here: Ubuntu UEC/Imanges.

We can use the Ubuntu cloud image catalog, and specifically use one that has been built to run on KVM. Since AHV is based on KVM/QEMU Nutanix can use that image format directly without any further conversion.

Using a cloud image can be a quicker way to stand up a particular version of Linux without having to go through the Linux installation process (choosing usernames, keyboard types, timezones etc.). However, you will need to pass in a public key so that you can login to the instance once it has booted.

Where to get your Ubuntu Cloud Imge

To use a released build rather than a nightly build head to the ubuntu Cloud Images Released page.

In this example we chose the 20.04 LTS “focal” release – latest available release.

Within this page I choose the kvm image ubuntu-20.04-server-cloudimg-amd64.img

Add the image to the cluster using Prism

Within Nutanix Prism Element, upload the image using the “Image Configuration” page. Once the image is uploaded to Prism, we can use it as a template to create VMs from.

Upload the Ubuntu Image to Prism

Creating a VM based on the Uploaded Template

In the VM page choose “Create VM”

In the “Add Disk” section – choose clone from Image service.

Choose the image that you just uploaded.

Add a NIC

Pass in the ssh key

Click on “Custom Script”. In here we will place the our key so that we can ssh into the VM. The cloud images do not allow login from console, so we need to provide a key. The key is your public key i.e. typically the contents of the file ~/.ssh/id_rsa.pub

#cloud-config
users:
  - name: nutanix
    shell: /bin/bash
    lock-passwd: false
    ssh_pwauth: True
    sudo: ALL=(ALL) NOPASSWD:ALL
    ssh_authorized_keys:
      - 

Paste your public key like so

#cloud-config
users:
  - name: nutanix
    shell: /bin/bash
    lock-passwd: false
    ssh_pwauth: True
    sudo: ALL=(ALL) NOPASSWD:ALL
    ssh_authorized_keys:
      - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwa3JtbNy+JREIEqtwPT6PICfr8G6gsqN1+K7MDI9tOTbRC8jyz5/ztI4u4egzHCmS+9QqW/Yp087VrQAUATWaxnB86l2EnLRk3LeDpGvjXnCjF+wxoOL08J7PdtTVNNn/uV2Rj3S/3sQLkTYAUzrdbk1fbZ3JcrKCQ4lkfUaUaoIN4BMhuDQNaDMQYzL+VbcFgnbHYAxsYx1dspqLCeDL+j4thIMKGy3Zjw1TghttvQV37PSW8k/EAgNC4TzAFZF9JWRXMtiljaXelGsd+MWKmaZ3Dk5ea9iUMXdd4cyjhz9K8wu53MIZSwnJDs0WARRmcW28r42uMzir1FE0bnIv nutanix@ubuntu-aws

Then save, and power on the VM.

To ssh to the ubuntu vm, using the example above the userid will be “nutanix

 ssh -i id_rsa.priv nutanix@10.0.0.78

That’s it.

Leave a Comment