Autoscaling for Instances
Configure Autoscaling in Red Hat OpenStack Platform
Abstract
Providing feedback on Red Hat documentation Copy linkLink copied to clipboard!
We appreciate your input on our documentation. Tell us how we can make it better.
Providing documentation feedback in Jira
Use the Create Issue form to provide feedback on the documentation. The Jira issue will be created in the Red Hat OpenStack Platform Jira project, where you can track the progress of your feedback.
- Ensure that you are logged in to Jira. If you do not have a Jira account, create an account to submit feedback.
- Click the following link to open a the Create Issue page: Create Issue
- Complete the Summary and Description fields. In the Description field, include the documentation URL, chapter or section number, and a detailed description of the issue. Do not modify any other fields in the form.
- Click Create.
Chapter 1. Introduction to autoscaling components Copy linkLink copied to clipboard!
Use telemetry components to collect data about your Red Hat OpenStack Platform (RHOSP) environment, such as CPU, storage, and memory usage. You can launch and scale instances in response to workload demand and resource availability. You can define the upper and lower bounds of telemetry data that control the scaling of instances in your Orchestration service (heat) templates.
Control automatic instance scaling with the following telemetry components:
- Data collection: Telemetry uses the data collection service (Ceilometer) to gather metric and event data.
- Storage: Telemetry stores metrics data in the time-series database service (gnocchi).
- Alarm: Telemetry uses the Alarming service (aodh) to trigger actions based on rules against metrics or event data collected by Ceilometer.
1.1. Data collection service (Ceilometer) for autoscaling Copy linkLink copied to clipboard!
You can use Ceilometer to collect data about metering and event information for Red Hat OpenStack Platform (RHOSP) components.
The Ceilometer service uses three agents to collect data from RHOSP components:
- A compute agent (ceilometer-agent-compute): Runs on each Compute node and polls for resource use statistics.
- A central agent (ceilometer-agent-central): Runs on the Controller nodes to poll for resource use statistics for resources that are not provided by Compute nodes.
- A notification agent (ceilometer-agent-notification): Runs on the Controller nodes and consumes messages from the message queues to build event and metering data.
The Ceilometer agents use publishers to send data to the corresponding end points, for example the time-series database service (gnocchi).
Additional resources
- Ceilometer in the Operational Measurements guide.
1.1.1. Publishers Copy linkLink copied to clipboard!
In Red Hat OpenStack Platform (RHOSP), you can use several transport methods to transfer the collected data into storage or external systems, such as Service Telemetry Framework (STF).
When you enable the gnocchi publisher, the measurement and resource information is stored as time-series data.
1.2. Time-series database service (gnocchi) for autoscaling Copy linkLink copied to clipboard!
Gnocchi is a time-series database that you can use for storing metrics in SQL. The Alarming service (aodh) and Orchestration service (heat) use the data stored in gnocchi for autoscaling.
Additional resources
1.3. Alarming service (aodh) Copy linkLink copied to clipboard!
You can configure the Alarming service (aodh) to trigger actions based on rules against metrics data collected by Ceilometer and stored in gnocchi. Alarms can be in one of the following states:
- Ok: The metric or event is in an acceptable state.
-
Firing: The metric or event is outside of the defined
Okstate. - insufficient data: The alarm state is unknown, for example, if there is no data for the requested granularity, or the check has not been executed yet, and so on.
1.4. Orchestration service (heat) for autoscaling Copy linkLink copied to clipboard!
Director uses Orchestration service (heat) templates as the template format for the overcloud deployment. Heat templates are usually expressed in YAML format. The purpose of a template is to define and create a stack, which is a collection of resources that heat creates, and the configuration of the resources. Resources are objects in Red Hat OpenStack Platform (RHOSP) and can include compute resources, network configuration, security groups, scaling rules, and custom resources.
Chapter 2. Configuring and deploying the overcloud for autoscaling Copy linkLink copied to clipboard!
You must configure the templates for the services on your overcloud that enable autoscaling.
Procedure
- Create environment templates and a resource registry for autoscaling services before you deploy the overcloud for autoscaling. For more information, see Section 2.1, “Configuring the overcloud for autoscaling”
- Deploy the overcloud. For more information, see Section 2.2, “Deploying the overcloud for autoscaling”
2.1. Configuring the overcloud for autoscaling Copy linkLink copied to clipboard!
Create the environment templates and resource registry that you need to deploy the services that provide autoscaling.
Procedure
-
Log in to the undercloud host as the
stackuser. Create a directory for the autoscaling configuration files:
mkdir -p $HOME/templates/autoscaling/
$ mkdir -p $HOME/templates/autoscaling/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the resource registry file for the definitions that the services require for autoscaling:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an environment template to configure the services required for autoscaling:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you use Red Hat Ceph Storage as the data storage back end for the time-series database service, add the following parameters to your
parameters-autoscaling.yamlfile:parameter_defaults: GnocchiRbdPoolName: 'metrics' GnocchiBackend: 'rbd'
parameter_defaults: GnocchiRbdPoolName: 'metrics' GnocchiBackend: 'rbd'Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must create the defined archive policy
genericbefore you can store metrics. You define this archive policy after the deployment. For more information, see Section 3.1, “Creating the generic archive policy for autoscaling”.-
Set the
polling_intervalparameter, for example, 60 seconds. The value of thepolling_intervalparameter must match the gnocchi granularity value that you defined when you created the archive policy. For more information, see Section 3.1, “Creating the generic archive policy for autoscaling”. - Deploy the overcloud. For more information, see Section 2.2, “Deploying the overcloud for autoscaling”
2.2. Deploying the overcloud for autoscaling Copy linkLink copied to clipboard!
You can deploy the overcloud for autoscaling by using director or by using a standalone environment.
Prerequisites
- You have created the environment templates for deploying the services that provide autoscaling capabilities. For more information, see Section 2.1, “Configuring the overcloud for autoscaling”.
Procedure
2.2.1. Deploying the overcloud for autoscaling by using director Copy linkLink copied to clipboard!
Use director to deploy the overcloud. If you are using a standalone environment, see Section 2.2.2, “Deploying the overcloud for autoscaling in a standalone environment”.
Prerequisites
- A deployed undercloud. For more information, see Installing director on the undercloud.
Procedure
-
Log in to the undercloud as the
stackuser. Source the
stackrcundercloud credentials file:source ~/stackrc
[stack@director ~]$ source ~/stackrcCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the autoscaling environment files to the stack with your other environment files and deploy the overcloud:
openstack overcloud deploy --templates \ -e [your environment files] \ -e $HOME/templates/autoscaling/parameters-autoscaling.yaml \ -e $HOME/templates/autoscaling/resources-autoscaling.yaml
(undercloud)$ openstack overcloud deploy --templates \ -e [your environment files] \ -e $HOME/templates/autoscaling/parameters-autoscaling.yaml \ -e $HOME/templates/autoscaling/resources-autoscaling.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2.2. Deploying the overcloud for autoscaling in a standalone environment Copy linkLink copied to clipboard!
To test the environment files in a pre-production environment, you can deploy the overcloud with the services required for autoscaling by using a standalone deployment.
This procedure uses example values and commands that you must change to suit a production environment.
If you want to use director to deploy the overcloud for autoscaling, see Section 2.2.1, “Deploying the overcloud for autoscaling by using director”.
Prerequisites
- An all-in-one RHOSP environment has been staged with the python3-tripleoclient. For more information, see Installing the all-in-one Red Hat OpenStack Platform environment.
- An all-in-one RHOSP environment has been staged with the base configuration. For more information, see Configuring the all-in-one Red Hat OpenStack Platform environment.
Procedure
Change to the user that manages your overcloud deployments, for example, the
stackuser:su - stack
[root@standalone ~]# su - stackCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace or set the environment variables
$IP,$NETMASKand$VIPfor the overcloud deployment:export IP=192.168.25.2 export VIP=192.168.25.3 export NETMASK=24
$ export IP=192.168.25.2 $ export VIP=192.168.25.3 $ export NETMASK=24Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the overcloud to test and verify the resource and parameter files:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Export the
OS_CLOUDenvironment variable:export OS_CLOUD=standalone
$ export OS_CLOUD=standaloneCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
2.3. Verifying the overcloud deployment for autoscaling Copy linkLink copied to clipboard!
Verify that the autoscaling services are deployed and enabled. Verification output is from a standalone environment, but director-based environments provide similar output.
Prerequisites
- You have deployed the autoscaling services in an existing overcloud using standalone or director. For more information, see Section 2.2, “Deploying the overcloud for autoscaling”.
Procedure
-
Log in to your environment as the
stackuser. For standalone environments set the
OS_CLOUDenvironment variable:export OS_CLOUD=standalone
[stack@standalone ~]$ export OS_CLOUD=standaloneCopy to Clipboard Copied! Toggle word wrap Toggle overflow For director environments, source the
overcloudrcovercloud credentials file:source ~/overcloudrc
[stack@undercloud ~]$ source ~/overcloudrcCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the deployment was successful and ensure that the service API endpoints for autoscaling are available:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the services are running on the overcloud:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the time-series database service is available:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 3. Using the heat service for autoscaling Copy linkLink copied to clipboard!
After you deploy the services required to provide autoscaling in the overcloud, you must configure the overcloud environment so that the Orchestration service (heat) can manage instances for autoscaling.
Prerequisites
- A deployed overcloud. For more information, see Section 2.2, “Deploying the overcloud for autoscaling”.
Procedure
3.1. Creating the generic archive policy for autoscaling Copy linkLink copied to clipboard!
After you deploy the services for autoscaling in the overcloud, you must configure the overcloud environment so that the Orchestration service (heat) can manage the instances for autoscaling.
Prerequisites
- You have deployed an overcloud that has autoscaling services. For more information, see Section 2.1, “Configuring the overcloud for autoscaling”.
Procedure
-
Log in to your environment as the
stackuser. For standalone environments, set the
OS_CLOUDenvironment variable:export OS_CLOUD=standalone
[stack@standalone ~]$ export OS_CLOUD=standaloneCopy to Clipboard Copied! Toggle word wrap Toggle overflow For director environments source the
stackrcfile:source ~/stackrc
[stack@undercloud ~]$ source ~/stackrcCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the archive policy defined in
$HOME/templates/autoscaling/parameters-autoscaling.yaml:openstack metric archive-policy create generic \ --back-window 0 \ --definition timespan:'4:00:00',granularity:'0:01:00',points:240 \ --aggregation-method 'rate:mean' \ --aggregation-method 'mean'
$ openstack metric archive-policy create generic \ --back-window 0 \ --definition timespan:'4:00:00',granularity:'0:01:00',points:240 \ --aggregation-method 'rate:mean' \ --aggregation-method 'mean'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the archive policy was created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.2. Configuring a heat template for automatically scaling instances Copy linkLink copied to clipboard!
You can configure an Orchestration service (heat) template to create the instances, and configure alarms that create and scale instances when triggered.
This procedure uses example values that you must change to suit your environment.
Prerequisites
- You have deployed the overcloud with the autoscaling services. For more information, see Section 2.2, “Deploying the overcloud for autoscaling”.
- You have configured the overcloud with an archive policy for autoscaling telemetry storage. For more information, see Section 3.1, “Creating the generic archive policy for autoscaling”.
Procedure
Log in to your environment as the
stackuser.source ~/overcloudrc
$ source ~/overcloudrcCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a directory to hold the instance configuration for the autoscaling group:
mkdir -p $HOME/templates/autoscaling/vnf/
$ mkdir -p $HOME/templates/autoscaling/vnf/Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Create an instance configuration template, for example,
$HOME/templates/autoscaling/vnf/instance.yaml. Add the following configuration to your
instance.yamlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
The
parametersparameter defines the custom parameters for this new resource. -
The
vnfsub-parameter of theresourcesparameter defines the name of the custom sub-resource referred to in theOS::Heat::AutoScalingGroup, for example,OS::Nova::Server::VNF.
-
The
Create the resource to reference in the heat template:
$ cat <<EOF > $HOME/templates/autoscaling/vnf/resources.yaml resource_registry: "OS::Nova::Server::VNF": $HOME/templates/autoscaling/vnf/instance.yaml EOF
$ cat <<EOF > $HOME/templates/autoscaling/vnf/resources.yaml resource_registry: "OS::Nova::Server::VNF": $HOME/templates/autoscaling/vnf/instance.yaml EOFCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the deployment template for heat to control instance scaling:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteOutputs on the stack are informational and are not referenced in the ScalingPolicy or AutoScalingGroup. To view the outputs, use the
openstack stack show <stack_name>command.
Additional resources
3.3. Preparing the standalone deployment for autoscaling Copy linkLink copied to clipboard!
To test the deployment of a stack for an autoscaled instance in a pre-production environment, you can deploy the stack by using a standalone deployment. You can use this procedure to test the deployment with a standalone environment. In a production environment, the deployment commands are different.
Procedure
-
Log in to your environment as the
stackuser. Set the
OS_CLOUDenvironment variable:export OS_CLOUD=standalone
[stack@standalone ~]$ export OS_CLOUD=standaloneCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the cloud to allow deployment of a simulated VNF workload that uses the Fedora 36 cloud image with attached private and public network interfaces. This example is a working configuration that uses a standalone deployment:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the flavor:
openstack flavor create --ram 2048 --disk 10 --vcpu 2 --public m1.small
$ openstack flavor create --ram 2048 --disk 10 --vcpu 2 --public m1.smallCopy to Clipboard Copied! Toggle word wrap Toggle overflow Download and import the Fedora 36 x86_64 cloud image:
curl -L 'https://download.fedoraproject.org/pub/fedora/linux/releases/36/Cloud/x86_64/images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2' -o $HOME/fedora36.qcow2
$ curl -L 'https://download.fedoraproject.org/pub/fedora/linux/releases/36/Cloud/x86_64/images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2' -o $HOME/fedora36.qcow2Copy to Clipboard Copied! Toggle word wrap Toggle overflow openstack image create fedora36 --container-format bare --disk-format qcow2 --public --file $HOME/fedora36.qcow2
$ openstack image create fedora36 --container-format bare --disk-format qcow2 --public --file $HOME/fedora36.qcow2Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate and import the public key:
ssh-keygen -f $HOME/.ssh/id_rsa -q -N "" -t rsa -b 2048
$ ssh-keygen -f $HOME/.ssh/id_rsa -q -N "" -t rsa -b 2048Copy to Clipboard Copied! Toggle word wrap Toggle overflow openstack keypair create --public-key $HOME/.ssh/id_rsa.pub default
$ openstack keypair create --public-key $HOME/.ssh/id_rsa.pub defaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
basicsecurity group that allows SSH, ICMP, and DNS protocols:openstack security group create basic
$ openstack security group create basicCopy to Clipboard Copied! Toggle word wrap Toggle overflow openstack security group rule create basic --protocol tcp --dst-port 22:22 --remote-ip 0.0.0.0/0
$ openstack security group rule create basic --protocol tcp --dst-port 22:22 --remote-ip 0.0.0.0/0Copy to Clipboard Copied! Toggle word wrap Toggle overflow openstack security group rule create --protocol icmp basic
$ openstack security group rule create --protocol icmp basicCopy to Clipboard Copied! Toggle word wrap Toggle overflow openstack security group rule create --protocol udp --dst-port 53:53 basic
$ openstack security group rule create --protocol udp --dst-port 53:53 basicCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the external network (public):
openstack network create --external --provider-physical-network datacentre --provider-network-type flat public
$ openstack network create --external --provider-physical-network datacentre --provider-network-type flat publicCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the private network:
openstack network create --internal private
$ openstack network create --internal privateCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow openstack subnet create private-net \ --subnet-range $PRIVATE_NETWORK_CIDR \ --network private
$ openstack subnet create private-net \ --subnet-range $PRIVATE_NETWORK_CIDR \ --network privateCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the router:
openstack router create vrouter
$ openstack router create vrouterCopy to Clipboard Copied! Toggle word wrap Toggle overflow openstack router set vrouter --external-gateway public
$ openstack router set vrouter --external-gateway publicCopy to Clipboard Copied! Toggle word wrap Toggle overflow openstack router add subnet vrouter private-net
$ openstack router add subnet vrouter private-netCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
3.4. Creating the stack deployment for autoscaling Copy linkLink copied to clipboard!
Create the stack deployment for the worked VNF autoscaling example.
Procedure
Log in to the undercloud host with your overcloud administrator credentials, for example
overcloudrc:source ~/overcloudrc
(undercloud)$ source ~/overcloudrcCopy to Clipboard Copied! Toggle word wrap Toggle overflow You must first launch the ephemeral Heat process to use the
openstack stackcommands:openstack tripleo launch heat --heat-dir /home/stack/overcloud-deploy/overcloud/heat-launcher --restore-db export OS_CLOUD=heat
(undercloud)$ openstack tripleo launch heat --heat-dir /home/stack/overcloud-deploy/overcloud/heat-launcher --restore-db (undercloud)$ export OS_CLOUD=heatCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the stack:
openstack stack create \ -t $HOME/templates/autoscaling/vnf/template.yaml \ -e $HOME/templates/autoscaling/vnf/resources.yaml \ vnf
$ openstack stack create \ -t $HOME/templates/autoscaling/vnf/template.yaml \ -e $HOME/templates/autoscaling/vnf/resources.yaml \ vnfCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the stack was created successfully:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the stack resources were created, including alarms, scaling policies, and the autoscaling group:
export STACK_ID=$(openstack stack show vnf -c id -f value)
$ export STACK_ID=$(openstack stack show vnf -c id -f value)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that an instance was launched by the stack creation:
openstack server list --long | grep $STACK_ID | 62e1b27c-8d9d-44a5-a0f0-80e7e6d437c7 | vn-dvaxcqb-6bqh2qd2fpif-hicmkm5dzjug-vnf-ywrydc5wqjjc | ACTIVE | None | Running | private=192.168.100.61, 192.168.25.99 | fedora36 | a6aa7b11-1b99-4c62-a43b-d0b7c77f4b72 | m1.small | 5cd46fec-50c2-43d5-89e8-ed3fa7660852 | nova | standalone-80.localdomain | metering.server_group='cb082cbd-535e-4779-84b0-98925e103f5e' |
$ openstack server list --long | grep $STACK_ID | 62e1b27c-8d9d-44a5-a0f0-80e7e6d437c7 | vn-dvaxcqb-6bqh2qd2fpif-hicmkm5dzjug-vnf-ywrydc5wqjjc | ACTIVE | None | Running | private=192.168.100.61, 192.168.25.99 | fedora36 | a6aa7b11-1b99-4c62-a43b-d0b7c77f4b72 | m1.small | 5cd46fec-50c2-43d5-89e8-ed3fa7660852 | nova | standalone-80.localdomain | metering.server_group='cb082cbd-535e-4779-84b0-98925e103f5e' |Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the alarms were created for the stack:
List the alarm IDs. The state of the alarms might reside in the
insufficient datastate for a period of time. The minimal period of time is the polling interval of the data collection and data storage granularity setting:Copy to Clipboard Copied! Toggle word wrap Toggle overflow List the resources for the stack and note the
physical_resource_idvalues for thecpu_alarm_highandcpu_alarm_lowresources.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The value of the
physical_resource_idmust match thealarm_idin the output of theopenstack alarm listcommand.
Verify that metric resources exist for the stack. Set the value of the
server_groupquery to the stack ID:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that measurements exist for the instance resources created through the stack:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the ephemeral Heat process from the undercloud:
openstack tripleo launch heat --kill
(undercloud)$ openstack tripleo launch heat --killCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 4. Testing and troubleshooting autoscaling Copy linkLink copied to clipboard!
Use the Orchestration service (heat) to automatically scale instances up and down based on threshold definitions. To troubleshoot your environment, you can look for errors in the log files and history records.
4.1. Testing automatic scaling up of instances Copy linkLink copied to clipboard!
You can use the Orchestration service (heat) to scale instances automatically based on the cpu_alarm_high threshold definition. When the CPU use reaches a value defined in the threshold parameter, another instance starts up to balance the load. The threshold value in the template.yaml file is set to 80%.
Procedure
-
Log in to the host environment as the
stackuser. For standalone environments set the
OS_CLOUDenvironment variable:export OS_CLOUD=standalone
[stack@standalone ~]$ export OS_CLOUD=standaloneCopy to Clipboard Copied! Toggle word wrap Toggle overflow For director environments source the
overcloudrcfile:source ~/overcloudrc
[stack@undercloud ~]$ source ~/overcloudrcCopy to Clipboard Copied! Toggle word wrap Toggle overflow Log in to the instance:
ssh -i ~/mykey.pem cirros@192.168.122.8
$ ssh -i ~/mykey.pem cirros@192.168.122.8Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run multiple
ddcommands to generate the load:sudo dd if=/dev/zero of=/dev/null & sudo dd if=/dev/zero of=/dev/null & sudo dd if=/dev/zero of=/dev/null &
[instance ~]$ sudo dd if=/dev/zero of=/dev/null & [instance ~]$ sudo dd if=/dev/zero of=/dev/null & [instance ~]$ sudo dd if=/dev/zero of=/dev/null &Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Exit from the running instance and return to the host.
After you run the
ddcommands, you can expect to have 100% CPU use in the instance. Verify that the alarm has been triggered:Copy to Clipboard Copied! Toggle word wrap Toggle overflow After approximately 60 seconds, Orchestration starts another instance and adds it to the group. To verify that an instance has been created, enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow After another short period of time, observe that the Orchestration service has autoscaled to three instances. The configuration is set to a maximum of three instances. Verify there are three instances:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.2. Testing automatic scaling down of instances Copy linkLink copied to clipboard!
You can use the Orchestration service (heat) to automatically scale down instances based on the cpu_alarm_low threshold. In this example, the instances are scaled down when CPU use is below 5%.
Procedure
From within the workload instance, terminate the running
ddprocesses and observe Orchestration begin to scale the instances back down.killall dd
$ killall ddCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Log in to the host environment as the
stackuser. For standalone environments set the
OS_CLOUDenvironment variable:export OS_CLOUD=standalone
[stack@standalone ~]$ export OS_CLOUD=standaloneCopy to Clipboard Copied! Toggle word wrap Toggle overflow For director environments source the
overcloudrcfile:source ~/overcloudrc
[stack@undercloud ~]$ source ~/overcloudrcCopy to Clipboard Copied! Toggle word wrap Toggle overflow When you stop the
ddprocesses, this triggers thecpu_alarm_low eventalarm. As a result, Orchestration begins to automatically scale down and remove the instances. Verify that the corresponding alarm has triggered:Copy to Clipboard Copied! Toggle word wrap Toggle overflow After a few minutes, Orchestration continually reduce the number of instances to the minimum value defined in the
min_sizeparameter of thescaleup_groupdefinition. In this scenario, themin_sizeparameter is set to1.
4.3. Troubleshooting for autoscaling Copy linkLink copied to clipboard!
If your environment is not working properly, you can look for errors in the log files and history records.
Procedure
-
Log in to the host environment as the
stackuser. For standalone environments set the
OS_CLOUDenvironment variable:export OS_CLOUD=standalone
[stack@standalone ~]$ export OS_CLOUD=standaloneCopy to Clipboard Copied! Toggle word wrap Toggle overflow For director environments source the
overcloudrcfile:source ~/overcloudrc
[stack@undercloud ~]$ source ~/overcloudrcCopy to Clipboard Copied! Toggle word wrap Toggle overflow You must first launch the ephemeral Heat process to use the
openstack stackcommands:openstack tripleo launch heat --heat-dir /home/stack/overcloud-deploy/overcloud/heat-launcher --restore-db export OS_CLOUD=heat
(undercloud)$ openstack tripleo launch heat --heat-dir /home/stack/overcloud-deploy/overcloud/heat-launcher --restore-db (undercloud)$ export OS_CLOUD=heatCopy to Clipboard Copied! Toggle word wrap Toggle overflow To retrieve information on state transitions, list the stack event records:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Read the alarm history log:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To view the records of scale-out or scale-down operations that heat collects for the existing stack, you can use the
awkcommand to parse theheat-engine.log:awk '/Stack UPDATE started/,/Stack CREATE completed successfully/ {print $0}' /var/log/containers/heat/heat-engine.log$ awk '/Stack UPDATE started/,/Stack CREATE completed successfully/ {print $0}' /var/log/containers/heat/heat-engine.logCopy to Clipboard Copied! Toggle word wrap Toggle overflow To view aodh-related information, examine the
evaluator.log:grep -i alarm /var/log/containers/aodh/evaluator.log | grep -i transition
$ grep -i alarm /var/log/containers/aodh/evaluator.log | grep -i transitionCopy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the ephemeral Heat process from the undercloud:
openstack tripleo launch heat --kill
(undercloud)$ openstack tripleo launch heat --killCopy to Clipboard Copied! Toggle word wrap Toggle overflow
4.4. Using CPU telemetry values for autoscaling threshold when using rate:mean aggregration Copy linkLink copied to clipboard!
When using the OS::Heat::Autoscaling heat orchestration template (HOT) and setting a threshold value for CPU, the value is expressed in nanoseconds of CPU time which is a dynamic value based on the number of virtual CPUs allocated to the instance workload. In this reference guide we’ll explore how to calculate and express the CPU nanosecond value as a percentage when using the Gnocchi rate:mean aggregration method.
4.4.1. Calculating CPU telemetry values as a percentage Copy linkLink copied to clipboard!
CPU telemetry is stored in Gnocchi (OpenStack time-series data store) as CPU utilization in nanoseconds. When using CPU telemetry to define autoscaling thresholds it is useful to express the values as a percentage of CPU utilization since that is more natural when defining the threshold values. When defining the scaling policies used as part of an autoscaling group, we can take our desired threshold defined as a percentage and calculate the required threshold value in nanoseconds which is used in the policy definitions.
| Value (ns) | Granularity (s) | Percentage |
|---|---|---|
| 60000000000 | 60 | 100 |
| 54000000000 | 60 | 90 |
| 48000000000 | 60 | 80 |
| 42000000000 | 60 | 70 |
| 36000000000 | 60 | 60 |
| 30000000000 | 60 | 50 |
| 24000000000 | 60 | 40 |
| 18000000000 | 60 | 30 |
| 12000000000 | 60 | 20 |
| 6000000000 | 60 | 10 |
4.4.2. Displaying instance workload vCPU as a percentage Copy linkLink copied to clipboard!
You can display the gnocchi-stored CPU telemetry data as a percentage rather than the nanosecond values for instances by using the openstack metric aggregates command.
Prerequisites
- Create a heat stack using the autoscaling group resource that results in an instance workload.
Procedure
- Login to your OpenStack environment as the cloud adminstrator.
Retrieve the ID of the autoscaling group heat stack:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the value of the stack ID to an environment variable:
export STACK_ID=$(openstack stack show vnf -c id -f value)
$ export STACK_ID=$(openstack stack show vnf -c id -f value)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Return the metrics as an aggregate by resource type instance (server ID) with the value calculated as a percentage. The aggregate is returned as a value of nanoseconds of CPU time. We divide that number by 1000000000 to get the value in seconds. We then divide the value by our granularity, which in this example is 60 seconds. That value is then converted to a percentage by multiplying by 100. Finally, we divide the total value by the number of vCPU provided by the flavor assigned to the instance, in this example a value of 2 vCPU, providing us a value expressed as a percentage of CPU time:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.4.3. Retrieving available telemetry for an instance workload Copy linkLink copied to clipboard!
Retrieve the available telemetry for an instance workload and express the vCPU utilization as a percentage.
Prerequisites
- Create a heat stack using the autoscaling group resource that results in an instance workload.
Procedure
- Login to your OpenStack environment as the cloud adminstrator.
Retrieve the ID of the autoscaling group heat stack:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the value of the stack ID to an environment variable:
export STACK_ID=$(openstack stack show vnf -c id -f value)
$ export STACK_ID=$(openstack stack show vnf -c id -f value)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the ID of the workload instance you want to return data for. We are using the server list long form and filtering for instances that are part of our autoscaling group:
openstack server list --long --fit-width | grep "metering.server_group='$STACK_ID'" | bc1811de-48ed-44c1-ae22-c01f36d6cb02 | vn-xlfb4jb-yhbq6fkk2kec-qsu2lr47zigs-vnf-y27wuo25ce4e | ACTIVE | None | Running | private=192.168.100.139, 192.168.25.179 | fedora36 | d21f1aaa-0077-4313-8a46-266c39b705c1 | m1.small | 692533fe-0912-417e-b706-5d085449db53 | nova | standalone.localdomain | metering.server_group='e0a15cee-34d1-418a-ac79-74ad07585730' |
$ openstack server list --long --fit-width | grep "metering.server_group='$STACK_ID'" | bc1811de-48ed-44c1-ae22-c01f36d6cb02 | vn-xlfb4jb-yhbq6fkk2kec-qsu2lr47zigs-vnf-y27wuo25ce4e | ACTIVE | None | Running | private=192.168.100.139, 192.168.25.179 | fedora36 | d21f1aaa-0077-4313-8a46-266c39b705c1 | m1.small | 692533fe-0912-417e-b706-5d085449db53 | nova | standalone.localdomain | metering.server_group='e0a15cee-34d1-418a-ac79-74ad07585730' |Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the instance ID for one of the returned instance workload names:
INSTANCE_NAME='vn-xlfb4jb-yhbq6fkk2kec-qsu2lr47zigs-vnf-y27wuo25ce4e' ; export INSTANCE_ID=$(openstack server list --name $INSTANCE_NAME -c ID -f value)
$ INSTANCE_NAME='vn-xlfb4jb-yhbq6fkk2kec-qsu2lr47zigs-vnf-y27wuo25ce4e' ; export INSTANCE_ID=$(openstack server list --name $INSTANCE_NAME -c ID -f value)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify metrics have been stored for the instance resource ID. If no metrics are available it’s possible not enough time has elapsed since the instance was created. If enough time has elapsed, you can check the logs for the data collection service in
/var/log/containers/ceilometer/and logs for the time-series database service gnocchi in/var/log/containers/gnocchi/:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify there are available measures for the resource metric and note the granularity value as we’ll use it when running the
openstack metric aggregatescommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the number of vCPU cores applied to the workload instance by reviewing the configured flavor for the instance workload:
openstack server show $INSTANCE_ID -cflavor -f value m1.small (692533fe-0912-417e-b706-5d085449db53) openstack flavor show 692533fe-0912-417e-b706-5d085449db53 -c vcpus -f value 2
$ openstack server show $INSTANCE_ID -cflavor -f value m1.small (692533fe-0912-417e-b706-5d085449db53) $ openstack flavor show 692533fe-0912-417e-b706-5d085449db53 -c vcpus -f value 2Copy to Clipboard Copied! Toggle word wrap Toggle overflow Return the metrics as an aggregate by resource type instance (server ID) with the value calculated as a percentage. The aggregate is returned as a value of nanoseconds of CPU time. We divide that number by 1000000000 to get the value in seconds. We then divide the value by our granularity, which in this example is 60 seconds (as previously retrieved with
openstack metric measures showcommand). That value is then converted to a percentage by multiplying by 100. Finally, we divide the total value by the number of vCPU provided by the flavor assigned to the instance, in this example a value of 2 vCPU, providing us a value expressed as a percentage of CPU time:Copy to Clipboard Copied! Toggle word wrap Toggle overflow