:_mod-docs-content-type: PROCEDURE
[id="adopting-autoscaling_{context}"]

= Adopting autoscaling services

[role="_abstract"]
To adopt services that enable autoscaling, you patch an existing `OpenStackControlPlane` custom resource (CR) where the Alarming services (aodh) are disabled. The patch starts the service with the configuration parameters that are provided by the {rhos_prev_long} environment.

.Prerequisites

* The source {OpenStackPreviousInstaller} environment is running.
* A Single Node OpenShift or OpenShift Local is running in the {rhocp_long} cluster.
* You have adopted the following services:
** MariaDB
** {identity_service_first_ref}
** {orchestration_first_ref}
** {telemetry}

.Procedure

. Patch the `OpenStackControlPlane` CR to deploy the autoscaling services:
+
----
$ oc patch openstackcontrolplane openstack --type=merge --patch '
spec:
  telemetry:
    enabled: true
    template:
      autoscaling:
        enabled: true
        aodh:
          passwordSelector:
            aodhService: AodhPassword
          databaseAccount: aodh
          databaseInstance: openstack
          secret: osp-secret
          serviceUser: aodh
        heatInstance: heat
'
----

. Inspect the aodh pods:
+
----
$ AODH_POD=`oc get pods -l service=aodh | tail -n 1 | cut -f 1 -d' '`
$ oc exec -t $AODH_POD -c aodh-api -- cat /etc/aodh/aodh.conf
----

. Check whether the aodh API service is registered in the {identity_service}:
+
----
$ openstack endpoint list | grep aodh
| d05d120153cd4f9b8310ac396b572926 | regionOne | aodh  | alarming  | True    | internal  | http://aodh-internal.openstack.svc:8042  |
| d6daee0183494d7a9a5faee681c79046 | regionOne | aodh  | alarming  | True    | public    | http://aodh-public.openstack.svc:8042    |
----

. Optional: Create aodh alarms with the `PrometheusAlarm` alarm type:
+
[NOTE]
You must use the `PrometheusAlarm` alarm type instead of `GnocchiAggregationByResourcesAlarm`.
+
----
$ openstack alarm create --name high_cpu_alarm \
--type prometheus \
--query "(rate(ceilometer_cpu{resource_name=~'cirros'})) * 100" \
--alarm-action 'log://' \
--granularity 15 \
--evaluation-periods 3 \
--comparison-operator gt \
--threshold 7000000000
----

.. Verify that the alarm is enabled:
+
----
$ openstack alarm list
+--------------------------------------+------------+------------------+-------------------+----------+
| alarm_id                             | type       | name             | state  | severity | enabled  |
+--------------------------------------+------------+------------------+-------------------+----------+
| 209dc2e9-f9d6-40e5-aecc-e767ce50e9c0 | prometheus | prometheus_alarm |   ok   |    low   |   True   |
+--------------------------------------+------------+------------------+-------------------+----------+
----
