第8章 Creating flavors for launching instances

An instance flavor is a resource template that specifies the virtual hardware profile for the instance. Cloud users must specify a flavor when they launch an instance.

A flavor can specify the quantity of the following resources the Compute service must allocate to an instance:

  • The number of vCPUs.
  • The RAM, in MB.
  • The root disk, in GB.
  • The virtual storage, including secondary ephemeral storage and swap disk.

You can specify who can use flavors by making the flavor public to all projects, or private to specific projects or domains.

Flavors can use metadata, also referred to as "extra specs", to specify instance hardware support and quotas. The flavor metadata influences the instance placement, resource usage limits, and performance. For a complete list of available metadata properties, see Flavor metadata.

You can also use the flavor metadata keys to find a suitable host aggregate to host the instance, by matching the extra_specs metadata set on the host aggregate. To schedule an instance on a host aggregate, you must scope the flavor metadata by prefixing the extra_specs key with the aggregate_instance_extra_specs: namespace. For more information, see Creating and managing host aggregates.

A Red Hat OpenStack Platform (RHOSP) deployment includes the following set of default public flavors that your cloud users can use.

表8.1 Default Flavors

NamevCPUsRAMRoot Disk Size

m1.nano

1

128 MB

1 GB

m1.micro

1

192 MB

1 GB

注記

Behavior set using flavor properties override behavior set using images. When a cloud user launches an instance, the properties of the flavor they specify override the properties of the image they specify.

8.1. Creating a flavor

You can create and manage specialized flavors for specific functionality or behaviors, for example:

  • Change default memory and capacity to suit the underlying hardware needs.
  • Add metadata to force a specific I/O rate for the instance or to match a host aggregate.

Procedure

  1. Create a flavor that specifies the basic resources to make available to an instance:

    (overcloud)$ openstack flavor create --ram <size_mb> \
     --disk <size_gb> --vcpus <no_vcpus> \
     [--private --project <project_id>] <flavor_name>
    • Replace <size_mb> with the size of RAM to allocate to an instance created with this flavor.
    • Replace <size_gb> with the size of root disk to allocate to an instance created with this flavor.
    • Replace <no_vcpus> with the number of vCPUs to reserve for an instance created with this flavor.
    • Optional: Specify the --private and --project options to make the flavor accessible only by a particular project or group of users. Replace <project_id> with the ID of the project that can use this flavor to create instances. If you do not specify the accessibility, the flavor defaults to public, which means that it is available to all projects.

      注記

      You cannot make a public flavor private after it has been created.

    • Replace <flavor_name> with a unique name for your flavor.

      For more information about flavor arguments, see Flavor arguments.

  2. Optional: To specify flavor metadata, set the required properties by using key-value pairs:

    (overcloud)$ openstack flavor set \
     --property <key=value> --property <key=value> ... <flavor_name>
    • Replace <key> with the metadata key of the property you want to allocate to an instance that is created with this flavor. For a list of available metadata keys, see Flavor metadata.
    • Replace <value> with the value of the metadata key you want to allocate to an instance that is created with this flavor.
    • Replace <flavor_name> with the name of your flavor.

      For example, an instance that is launched by using the following flavor has two CPU sockets, each with two CPUs:

      (overcloud)$ openstack flavor set \
       --property hw:cpu_sockets=2 \
       --property hw:cpu_cores=2 processor_topology_flavor