Creating a Virtual Machine on a Dedicated Host in K5

Fujitsu’s Cloud Service K5 provides customers with the ability to deploy Virtual Machines that run on dedicated hosts assigned to a customers environment, Fujitsu call this Virtual Private Cloud.

In order to create Virtual Machines you will first need to ensure that you have asked Fujitsu to provide some dedicated hosts to your environment.

NOTE: You can mix a K5 Public Cloud and K5 Virtual Private Cloud environment within a single account.

Virtual Machines running on dedicated hosts can only be configured through the K5 APIs, the following details out how to create a KVM based Virtual Machine on a dedicated host on K5:

Step 1: Authenticate

Authenticate and scope to the project in K5 where your dedicated hosts have been assigned. See theFujitsu K5 GitHub repository for an example of how to do this:

https://github.com/fujitsuk5/K5-Auth-API

Step 2: Retrieve a List of Virtual Machine Flavors

Once you have authenticated and obtained a Token you can then go on and retrieve a list of Virtual Machine Flavors that K5 provides.

You will need to issue a GET request to the Compute API endpoint in the region you want to query, for example to query the UK region of K5 for a list of Flavors:

GET https://compute.uk-1.cloud.global.fujitsu.com/v2/flavors

An example of this request using curl:

curl -i -H "X-Auth-Token: TOKEN_ID" -H "accepts:application/json" https://compute.uk-1.cloud.global.fujitsu.com/v2/flavors

At the time of writing this blog the following Flavors are available:

ID Name CPU RAM
1101 S-1 1 vCPU 4GB
1102 S-2 2 vCPU 8GB
1103 S-4 4 vCPU 16GB
1104 S-8 8 vCPU 32GB
1105 S-16 16 vCPU 64GB
1201 M-1 1 vCPU 8GB
1202 M-2 2 vCPU 16GB
1203 M-4 4 vCPU 32GB
1204 M-8 8 vCPU 64GB
1205 M-16 16 vCPU 128GB
1503 XM-4 4 vCPU 128GB

Step 3: Retrieve a List of Images

Now that we have the list of available images to choose for deployment we need to obtain a list of Images that we can deploy.

You will need execute the following to obtain a list of Images.

GET https://image.uk-1.cloud.global.fujitsu.com/v2/images

An example of the request using curl:

curl -i -H "X-Auth-Token: TOKEN_ID" -H "accepts:application/json" https://image.uk-1.cloud.global.fujitsu.com/v2/images

At the time of writing this blog the following Images are available in the UK deployment of K5:

ID Name
37a9d80a-f014-4424-826e-a6e5ae397a3d Windows Server 2012 R2 SE 64bit + SQL Server 2014 SE SP2 (English) 01
41857965-6ee8-4393-94b3-299a0c6988cc Red Hat Enterprise Linux 7.2 64bit (English) 01
20403cb8-4ada-4c5a-b524-d1ff393f0bb7 Windows Server 2008 R2 SE SP1 64bit (English) 01
6e1610db-1115-4260-8dc2-bcdd526a54be Windows Server 2012 R2 SE 64bit (English) 01
58fd966f-b055-4cd0-9012-cf6af7a4c32b CentOS 7.2 64bit (English) 01
0e330855-aeff-423c-99b2-7ee16adb5f68 FJK5-NAS-V02
2d1b7b6b-93cf-4a9b-aacc-43ce61b8073c CentOS 6.5 64bit (English) 04
ffa17298-537d-40b2-a848-0a4d22b49df5 Ubuntu Server 14.04 LTS (English) 01
db9766f0-c95c-4f1c-bb29-304a90405e3e Red Hat Enterprise Linux 6.5 64bit (English) 02

Step 4: Retrieve a List of Networks

Assuming that you already have a virtual network created within your K5 project then you can obtain a list of networks by:

GET https://network.uk-1.cloud.global.com/v2/networks

An example of the request using curl:

curl -i -H "X-Auth-Token: TOKEN_ID" -H "accepts:application/json" https://network.uk-1.cloud.global.fujitsu.com/v2/networks

This will return a list of networks and their associated details that we’ll need later.

Step 5: Create Virtual Machine

We now have all the prerequisite pieces of information we need to build a virtual machine in K5. This time we will make a POST request to the compute API endpoint and pass a JSON payload in the request that tells K5 what to deploy.

An example of the JSON payload we will be sending:

{
"server":
{
"name": "<SOME_NAME>",
"availability_zone": "UK-1a",
"imageRef": "",
"flavorRef": "<FLAVOR_ID_WE_GOT_EARLIER",
"block_device_mapping_v2":
[{
"boot_index": "0",
"uuid":"<IMAGE_ID_WE_GOT_EARLIER>",
"volume_size": "100",
"device_name":"/dev/vda",
"source_type": "image",
"destination_type": "volume",
"delete_on_termination": "True"
}],
"key_name": "<KEY_PAIR_NAME>",
"max_count": 1,
"min_count": 1,
"networks":
[{
"uuid": "<NETWORK_ID_WE_GOT_EARLIER>"
}],
"security_groups":
[{
"name": ""
}]
},
"OS-SCH-HNT:scheduler_hints":
{
"fcx.dedicated": "True"
}
}

You will need to replace the variables in the above JSON payload example with the ones you want (Availability Zone, Image ID, Flavor ID, Network ID, Key Name).

Take note of the last section “OS-SCH-HNT:scheduler_hints”. It’s the “fcx.dedicted: True” part of the JSON payload that tells K5 that this Virtual Machine request should be deployed on the Dedicated Hosts.

Execute a POST request to the following URL passing the JSON above as the payload:

POST https://compute.uk-1.cloud.global.fujitsu.com/v2/<PROJECT_ID>/servers

Replace <PROJECT_ID> with the Project ID you want to deploy the Virtual Server to.

And there we have it, K5 will now be provisioning a Virtual Machine on a Dedicated Host and should appear in the K5 portal for you to manage.

Advertisements