Wednesday, September 19, 2018

X-Ray Custom Scenarios Explained: 1. Configuration definitions


X-Ray team made their builtin scenarios open source a few months ago. I hope this blog series would help one to write their own custom scenarios.

Scenario definition file called test.yml is placed in a unique custom scenario directory. This file consists of several sections as described in the picture below. Scenario file is in YML format and parsed with the help of Jinja2 parser and ansible playbook.

The following picture does not include documentation and UI related information typically exist in the scenario file.




In this part-1, let's look at syntax for configuration definitions.

VARS:

In the following example, 3 variables "vms_per_node", "num_nodes" and "runtime_secs" are defined. Each variable definition can have default, min and max.

vars:
  vms_per_node:
    default: 1
    min: 1
    max: 4
  num_nodes:
    default: 4
    min: 1
  runtime_secs:
    default: 7200
    min: 1
    max: 14400

VM Groups (or) VMS:

VM Groups definition essentially got two parts. First part is about defining VM config itself such as vcpus, ram, disks, etc. The second part is about defining the number of VMs and their placements. Typically the number of VMs are scaled per cluster or node.

X-Ray comes with builtin VM template called "ubuntu1604".  This template has FIO pre-installed which is the primary I/O load generator.

Ok. Let's look at the simple one first.

vms:
  - VDI_1VM_Per_Cluster:
      template: ubuntu1604
      vcpus: 2
      ram_mb: 2048
      data_disks:
        count: 1
        size: 16
      nodes: all
      count_per_cluster: 1

VM Group called "VDI_1VM_Per_Cluster" is defined with VM config of 2 vcpus, 2GB memory and 1 data disk of 16GB in size. As defined in "count_per_cluster", it just brings up a single VM per cluster on the first node available in the cluster.

  - VDI_2VM_per_Node:
      template: ubuntu1604
      vcpus: 2
      ram_mb: 2048
      data_disks:
        count: 1
        size: 16
      nodes: all
      count_per_node: 2

VM Group called "VDI_2VM_Per_Node" is going to create 2 VMs per node on all nodes available in the cluster. If cluster size is 4, then 4*2=8 VMs are created in the cluster as 2 VM per node.

  - VDI_4VMs:
      template: ubuntu1604
      vcpus: 2
      ram_mb: 2048
      data_disks:
        count: 1
        size: 16
      nodes: 0,1
      count_per_node: 2

VM Group called "VDI_4VMs" is going to create 2 VMs per node on first (0) and second (1) nodes available in the cluster as total of 4.

Ok. What if one wants to create one or more VM Groups per node and scale dynamically, here jinja2 syntax come in handy. Let's define number of nodes in a variable and define VM groups
vars:
  num_nodes:
    default: 4
    min: 1

vms:
{% for node_index in range(num_nodes) %}
  - VM Group for Node {{ node_index }}:
      template: ubuntu1604
      vcpus: 4
      ram_mb: 4096
      data_disks:
        count: 6
        size: 64
      nodes: {{ node_index }}
      count_per_node: 2
{% endfor %}



No comments:

Post a Comment