Questo contenuto non è disponibile nella lingua selezionata.
Chapter 3. Using the heat service for autoscaling
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 Copia collegamentoCollegamento copiato negli appunti!
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 Copia collegamentoCollegamento copiato negli appunti!
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 Copia collegamentoCollegamento copiato negli appunti!
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 Copia collegamentoCollegamento copiato negli appunti!
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
$ 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