From 0228574e5c3e5b44a3b7c91c199d06278d95998a Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Thu, 2 May 2024 11:59:59 +0100 Subject: [PATCH] Initial stab at fio benchmarking resources --- openstack/fio_bench/00-init.tf | 1 + openstack/fio_bench/00-vars.tf | 9 +++++ openstack/fio_bench/01-flavor.tf | 13 +++++++ openstack/fio_bench/01-sec-groups.tf | 24 ++++++++++++ openstack/fio_bench/02-network.tf | 24 ++++++++++++ openstack/fio_bench/03-instance.tf | 55 ++++++++++++++++++++++++++++ openstack/fio_bench/terraform.tfvars | 1 + openstack/fio_bench/user-data.yaml | 16 ++++++++ 8 files changed, 143 insertions(+) create mode 120000 openstack/fio_bench/00-init.tf create mode 100644 openstack/fio_bench/00-vars.tf create mode 100644 openstack/fio_bench/01-flavor.tf create mode 100644 openstack/fio_bench/01-sec-groups.tf create mode 100644 openstack/fio_bench/02-network.tf create mode 100644 openstack/fio_bench/03-instance.tf create mode 120000 openstack/fio_bench/terraform.tfvars create mode 100644 openstack/fio_bench/user-data.yaml diff --git a/openstack/fio_bench/00-init.tf b/openstack/fio_bench/00-init.tf new file mode 120000 index 0000000..b015707 --- /dev/null +++ b/openstack/fio_bench/00-init.tf @@ -0,0 +1 @@ +../00-init.tf \ No newline at end of file diff --git a/openstack/fio_bench/00-vars.tf b/openstack/fio_bench/00-vars.tf new file mode 100644 index 0000000..c6e568d --- /dev/null +++ b/openstack/fio_bench/00-vars.tf @@ -0,0 +1,9 @@ +variable "volume_type" { + type = string + default = "cinder-t3" +} + +variable "image" { + type = string + default = "bionic" +} diff --git a/openstack/fio_bench/01-flavor.tf b/openstack/fio_bench/01-flavor.tf new file mode 100644 index 0000000..bc052a2 --- /dev/null +++ b/openstack/fio_bench/01-flavor.tf @@ -0,0 +1,13 @@ +resource "openstack_compute_flavor_v2" "canonical_m1_xlarge_fio" { + name = "canonical.m1.xlarge.fio" + ram = "16384" + vcpus = "8" + disk = "160" + is_public = true + + extra_specs = { + "hw:cpu_policy" = "dedicated", + "hw:cpu_thread_policy" = "prefer" + "hw:numa_nodes" = "1" + } +} diff --git a/openstack/fio_bench/01-sec-groups.tf b/openstack/fio_bench/01-sec-groups.tf new file mode 100644 index 0000000..b0fff4d --- /dev/null +++ b/openstack/fio_bench/01-sec-groups.tf @@ -0,0 +1,24 @@ +resource "openstack_networking_secgroup_v2" "server_secgroup_test" { + name = "server_secgroup_test" + description = "Allow ssh and ping" +} + +resource "openstack_networking_secgroup_rule_v2" "server_secgroup_test_ping" { + direction = "ingress" + ethertype = "IPv4" + protocol = "icmp" + port_range_min = -1 + port_range_max = -1 + remote_ip_prefix = "0.0.0.0/0" + security_group_id = openstack_networking_secgroup_v2.server_secgroup_test.id +} + +resource "openstack_networking_secgroup_rule_v2" "server_secgroup_test_ssh" { + direction = "ingress" + ethertype = "IPv4" + protocol = "tcp" + port_range_min = 22 + port_range_max = 22 + remote_ip_prefix = "0.0.0.0/0" + security_group_id = openstack_networking_secgroup_v2.server_secgroup_test.id +} diff --git a/openstack/fio_bench/02-network.tf b/openstack/fio_bench/02-network.tf new file mode 100644 index 0000000..9339f8e --- /dev/null +++ b/openstack/fio_bench/02-network.tf @@ -0,0 +1,24 @@ +resource "openstack_networking_network_v2" "network_test" { + name = "network_test" + admin_state_up = "true" + + segments { + physical_network = "physnet_sriov1" + segmentation_id = "1498" + network_type = "vlan" + } +} + +resource "openstack_networking_subnet_v2" "subnet_test" { + network_id = openstack_networking_network_v2.network_test.id + name = "server_test_sn" + cidr = "10.0.9.0/24" + + enable_dhcp = "false" + + allocation_pool { + start = "10.0.9.36" + end = "10.0.9.62" + } + +} diff --git a/openstack/fio_bench/03-instance.tf b/openstack/fio_bench/03-instance.tf new file mode 100644 index 0000000..b53f8dc --- /dev/null +++ b/openstack/fio_bench/03-instance.tf @@ -0,0 +1,55 @@ +data "openstack_images_image_v2" "image" { + name = var.image + most_recent = true +} + + +resource "openstack_blockstorage_volume_v3" "volume_data" { + name = "volume_data" + size = 200 + volume_type = var.volume_type +} + +resource "openstack_blockstorage_volume_v3" "volume_boot" { + name = "volume_boot" + size = 10 + image_id = data.openstack_images_image_v2.image.id + volume_type = var.volume_type +} + +resource "openstack_networking_port_v2" "server_port" { + name = "server_eth0" + network_id = openstack_networking_network_v2.network_test.id + admin_state_up = "true" + security_group_ids = [openstack_networking_secgroup_v2.server_secgroup_test.id] + binding { + vnic_type = "direct" + } +} + +resource "openstack_compute_instance_v2" "server_test" { + name = "fio_test_server" + image_id = data.openstack_images_image_v2.image.id + flavor_id = openstack_compute_flavor_v2.canonical_m1_xlarge_fio.id + config_drive = "true" + + block_device { + uuid = openstack_blockstorage_volume_v3.volume_boot.id + source_type = "volume" + boot_index = 0 + destination_type = "volume" + } + + block_device { + uuid = openstack_blockstorage_volume_v3.volume_data.id + source_type = "volume" + boot_index = 1 + destination_type = "volume" + } + + network { + port = openstack_networking_port_v2.server_port.id + } + + user_data = file("user-data.yaml") +} diff --git a/openstack/fio_bench/terraform.tfvars b/openstack/fio_bench/terraform.tfvars new file mode 120000 index 0000000..c196d0f --- /dev/null +++ b/openstack/fio_bench/terraform.tfvars @@ -0,0 +1 @@ +../arif-home.tfvars \ No newline at end of file diff --git a/openstack/fio_bench/user-data.yaml b/openstack/fio_bench/user-data.yaml new file mode 100644 index 0000000..505d8c1 --- /dev/null +++ b/openstack/fio_bench/user-data.yaml @@ -0,0 +1,16 @@ +#cloud-config +password: ubuntu +chpasswd: {expire: False} +ssh_pwauth: True +write_files: +- content: | + #!/bin/bash + + sudo mkfs.ext4 /dev/vdb + sudo mkdir /mnt/disk + sudo mount /dev/vdb /mnt/disk + owner: root + permissions: '0755' + path: /tmp/mount_disk.sh +runcmd: + - [ sudo, /tmp/mount_disk.sh ]