Provisioning Fedora CoreOS on Nutanix AHV

This guide shows how to provision new Fedora CoreOS (FCOS) nodes on Nutanix AHV. Fedora currently does not publish Fedora CoreOS images within Nutanix, so you need to upload a Nutanix image to your Nutanix Prism Central subscription.

Prerequisites

Before provisioning an FCOS machine, you must have an Ignition configuration file containing your customizations. If you do not have one, see Producing an Ignition File.

Fedora CoreOS has a default core user that can be used to explore the OS. If you want to use it, finalize its configuration by providing e.g. an SSH key.

You also need to have access to a Nutanix Prism Central subscription. The examples below use the curl command to access Nutanix Prism Central APIs.

Uploading an image to Nutanix AHV

Fedora CoreOS is designed to be updated automatically, with different schedules per stream. Once you have picked the relevant stream, use the Nutanix Prism Central API to upload the latest image to Nutanix:

STREAM=stable
IMAGE_NAME=<name of image to create>
API_HOST=<Prism Central hostname>
API_USERNAME=<username>
API_PASSWORD=<password>

URL=$(curl https://builds.coreos.fedoraproject.org/streams/${STREAM}.json | \
    jq -r .architectures.x86_64.artifacts.nutanix.formats.qcow2.disk.location)
ENCODED_CREDS="$(echo -n "${API_USERNAME}:${API_PASSWORD}" | base64)"

curl -X POST --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --header "Authorization: Basic ${ENCODED_CREDS}" \
    "https://${API_HOST}:9440/api/nutanix/v3/images" \
    -d @- << EOF
{
  "spec": {
    "name": "${IMAGE_NAME}",
    "resources": {
      "image_type": "ISO_IMAGE",
      "source_uri": "${URL}",
      "architecture": "X86_64",
      "source_options": {
        "allow_insecure_connection": false
      }
    },
    "description": "string"
  },
  "api_version": "3.1.0",
  "metadata": {
    "use_categories_mapping": false,
    "kind": "image",
    "spec_version": 0,
    "categories_mapping": {},
    "should_force_translate": true,
    "entity_version": "string",
    "categories": {},
    "name": "string"
  }
}
EOF

Launching a VM instance

You can provision an FCOS instance using the Nutanix Prism Central web portal or via the Prism Central API with curl. Ignition configuration can be passed to the VM as a "cloud-init custom script". For example, to launch a VM using the API:

API_HOST=<Prism Central hostname>
API_USERNAME=<username>
API_PASSWORD=<password>
CLUSTER_REFERENCE_NAME=<name of cluster to use>
CLUSTER_REFERENCE_UUID=<uuid of cluster to use>
SUBNET_REFERENCE_NAME=<name of subnet to use>
SUBNET_REFERENCE_UUID=<uuid of subnet to use>
VM_NAME=<name of VM to create>
IGNITION_CONFIG=config.ign
IMAGE_NAME=<name of image>

ENCODED_CONFIG="$(cat ${IGNITION_CONFIG} | base64 -w 0)"
ENCODED_CREDS="$(echo -n "${API_USERNAME}:${API_PASSWORD}" | base64)"
IMAGE_ID=$(curl -X POST --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --header "Authorization: Basic ${ENCODED_CREDS}" \
    "https://${API_HOST}:9440/api/nutanix/v3/images/list"
    -d '{ "kind": "image","filter": "", "length": 30, "offset": 0}' | \
    jq -r '.entities[] | select(.spec.name == "${IMAGE_NAME}") | .metadata.uuid')


curl -X POST --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --header "Authorization: Basic ${ENCODED_CREDS}" \
    "https://${API_HOST}:9440/api/nutanix/v3/vms" \
    -d @- << EOF
{
   "spec": {
      "name": "${VM_NAME}",
      "resources": {
         "power_state": "ON",
         "num_vcpus_per_socket": 1,
         "num_sockets": 1,
         "memory_size_mib": 16384,
         "disk_list": [
            {
               "disk_size_mib": 32768,
               "device_properties": {
                  "device_type": "DISK",
                  "disk_address": {
                     "device_index": 0,
                     "adapter_type": "SCSI"
                  }
               },
               "data_source_reference": {
                  "kind": "image",
                  "uuid": "${IMAGE_ID}"
               }
            }
         ],
         "nic_list": [
            {
               "nic_type": "NORMAL_NIC",
               "is_connected": true,
               "ip_endpoint_list": [
                  {
                     "ip_type": "DHCP"
                  }
               ],
               "subnet_reference": {
                  "kind": "subnet",
                  "name": "${SUBNET_REFERENCE_NAME}",
                  "uuid": "${SUBNET_REFERENCE_UUID}"
               }
            }
         ],
         "guest_tools": {
            "nutanix_guest_tools": {
               "state": "ENABLED",
               "iso_mount_state": "MOUNTED"
            }
         },
         "guest_customization": {
            "cloud_init": {
               "user_data": "${ENCODED_CONFIG}"
            },
            "is_overridable": false
         }
      },
      "cluster_reference": {
         "kind": "cluster",
         "name": "${CLUSTER_REFERENCE_NAME}",
         "uuid": "${CLUSTER_REFERENCE_UUID}"
      }
   },
   "api_version": "3.1.0",
   "metadata": {
      "kind": "vm"
   }
}
EOF

You now should be able to SSH into the instance using the associated IP address.

Example connecting
ssh core@<ip address>