Add support for OpenSearch 2.x as CloudKitty storage backend

Depends-On: https://review.opendev.org/c/openstack/cloudkitty/+/880739
Change-Id: Ib8d7182cc4b8a0c7d320ba2c51b2157782030317
This commit is contained in:
Pierre Riteau 2024-05-16 09:07:59 +02:00
parent 78e7f133f0
commit 8581497acb
7 changed files with 89 additions and 13 deletions

View File

@ -879,7 +879,7 @@ skip_stop_containers: []
# services with ElasticSearch endpoints should be configured to log # services with ElasticSearch endpoints should be configured to log
# to the external cluster by default. This is for backwards compatibility. # to the external cluster by default. This is for backwards compatibility.
opensearch_address: "{{ elasticsearch_address if elasticsearch_address is defined else kolla_internal_fqdn }}" opensearch_address: "{{ elasticsearch_address if elasticsearch_address is defined else kolla_internal_fqdn }}"
enable_opensearch: "{{ enable_central_logging | bool or enable_osprofiler | bool or (enable_cloudkitty | bool and cloudkitty_storage_backend == 'elasticsearch') }}" enable_opensearch: "{{ enable_central_logging | bool or enable_osprofiler | bool or (enable_cloudkitty | bool and cloudkitty_storage_backend == 'opensearch') }}"
enable_opensearch_dashboards: "{{ enable_opensearch | bool }}" enable_opensearch_dashboards: "{{ enable_opensearch | bool }}"
enable_opensearch_dashboards_external: "{{ enable_opensearch_dashboards | bool }}" enable_opensearch_dashboards_external: "{{ enable_opensearch_dashboards | bool }}"

View File

@ -165,11 +165,13 @@ cloudkitty_influxdb_cafile: "{{ openstack_cacert }}"
cloudkitty_influxdb_name: "cloudkitty" cloudkitty_influxdb_name: "cloudkitty"
# Set the elasticsearch index name. # Set the elasticsearch/opensearch index name.
cloudkitty_elasticsearch_index_name: "cloudkitty" cloudkitty_elasticsearch_index_name: "cloudkitty"
cloudkitty_opensearch_index_name: "{{ cloudkitty_elasticsearch_index_name }}"
# Set the elasticsearch host URL. # Set the elasticsearch/opensearch host URL.
cloudkitty_elasticsearch_url: "{{ internal_protocol }}://{{ opensearch_address }}:{{ opensearch_port }}" cloudkitty_elasticsearch_url: "{{ internal_protocol }}://{{ opensearch_address }}:{{ opensearch_port }}"
cloudkitty_opensearch_url: "{{ cloudkitty_elasticsearch_url }}"
# Path of the CA certificate to trust for HTTPS connections. # Path of the CA certificate to trust for HTTPS connections.
cloudkitty_elasticsearch_cafile: "{{ openstack_cacert }}" cloudkitty_elasticsearch_cafile: "{{ openstack_cacert }}"
@ -178,6 +180,14 @@ cloudkitty_elasticsearch_cafile: "{{ openstack_cacert }}"
# This means, HTTPS connections without validating the certificate used by elasticsearch # This means, HTTPS connections without validating the certificate used by elasticsearch
cloudkitty_elasticsearch_insecure_connections: false cloudkitty_elasticsearch_insecure_connections: false
# Path of the CA certificate to trust for HTTPS connections.
cloudkitty_opensearch_cafile: "{{ openstack_cacert }}"
# Set to true to authorize insecure HTTPS connections to OpenSearch.
# This means, HTTPS connections without validating the certificate used by
# OpenSearch.
cloudkitty_opensearch_insecure_connections: false
#################### ####################
# Collector # Collector
#################### ####################

View File

@ -62,9 +62,22 @@
status_code: 200, 404 status_code: 200, 404
run_once: true run_once: true
delegate_to: "{{ groups['cloudkitty-api'][0] }}" delegate_to: "{{ groups['cloudkitty-api'][0] }}"
register: cloudkitty_index register: cloudkitty_index_elasticsearch
when: cloudkitty_storage_backend == 'elasticsearch' when: cloudkitty_storage_backend == 'elasticsearch'
- name: Checking if Cloudkitty opensearch index exists
become: true
kolla_toolbox:
container_engine: "{{ kolla_container_engine }}"
module_name: uri
module_args:
url: "{{ cloudkitty_opensearch_url }}/{{ cloudkitty_opensearch_index_name }}"
status_code: 200, 404
run_once: true
delegate_to: "{{ groups['cloudkitty-api'][0] }}"
register: cloudkitty_index_opensearch
when: cloudkitty_storage_backend == 'opensearch'
- name: Creating Cloudkitty elasticsearch index - name: Creating Cloudkitty elasticsearch index
become: true become: true
kolla_toolbox: kolla_toolbox:
@ -82,6 +95,25 @@
delegate_to: "{{ groups['cloudkitty-api'][0] }}" delegate_to: "{{ groups['cloudkitty-api'][0] }}"
when: when:
- cloudkitty_storage_backend == 'elasticsearch' - cloudkitty_storage_backend == 'elasticsearch'
- cloudkitty_index.get('status') != 200 - cloudkitty_index_elasticsearch.get('status') != 200
- name: Creating Cloudkitty opensearch index
become: true
kolla_toolbox:
container_engine: "{{ kolla_container_engine }}"
module_name: uri
module_args:
url: "{{ cloudkitty_opensearch_url }}/{{ cloudkitty_opensearch_index_name }}"
method: PUT
status_code: 200
return_content: yes
body: |
{}
body_format: json
run_once: True
delegate_to: "{{ groups['cloudkitty-api'][0] }}"
when:
- cloudkitty_storage_backend == 'opensearch'
- cloudkitty_index_opensearch.get('status') != 200
- import_tasks: bootstrap_service.yml - import_tasks: bootstrap_service.yml

View File

@ -154,8 +154,18 @@ host = {{ cloudkitty_elasticsearch_url }}
index_name = {{ cloudkitty_elasticsearch_index_name }} index_name = {{ cloudkitty_elasticsearch_index_name }}
insecure = {{ cloudkitty_elasticsearch_insecure_connections }} insecure = {{ cloudkitty_elasticsearch_insecure_connections }}
{% if cloudkitty_elasticsearch_cafile is defined %} {% if cloudkitty_elasticsearch_cafile | length > 0 %}
cafile = {{ cloudkitty_elasticsearch_cafile }} cafile = {{ cloudkitty_elasticsearch_cafile }}
{% endif %} {% endif %}
{% endif %}
{% if cloudkitty_storage_backend == 'opensearch' %}
[storage_opensearch]
host = {{ cloudkitty_opensearch_url }}
index_name = {{ cloudkitty_opensearch_index_name }}
insecure = {{ cloudkitty_opensearch_insecure_connections }}
{% if cloudkitty_opensearch_cafile | length > 0 %}
cafile = {{ cloudkitty_opensearch_cafile }}
{% endif %}
{% endif %} {% endif %}

View File

@ -62,14 +62,22 @@ Cloudkitty Storage Backend
As for collectors, CloudKitty supports multiple backend to store ratings. As for collectors, CloudKitty supports multiple backend to store ratings.
By default, Kolla Ansible uses the InfluxDB based backend. By default, Kolla Ansible uses the InfluxDB based backend.
Another famous alternative is Elasticsearch and can be activated in Kolla Another famous alternative is OpenSearch and can be activated in Kolla
Ansible using the ``cloudkitty_storage_backend`` configuration option in Ansible using the ``cloudkitty_storage_backend`` configuration option in
your ``globals.yml`` configuration file: your ``globals.yml`` configuration file:
.. code-block:: yaml .. code-block:: yaml
cloudkitty_storage_backend: elasticsearch cloudkitty_storage_backend: opensearch
You can only use one backend type at a time, selecting elasticsearch Using an external Elasticsearch backend is still possible with the following
will automatically enable Elasticsearch deployment and creation of the configuration:
.. code-block:: yaml
cloudkitty_storage_backend: elasticsearch
cloudkitty_elasticsearch_url: http://HOST:PORT
You can only use one backend type at a time, selecting ``opensearch``
will automatically enable OpenSearch deployment and creation of the
required CloudKitty index. required CloudKitty index.

View File

@ -409,7 +409,7 @@ workaround_ansible_issue_8743: yes
#enable_octavia: "no" #enable_octavia: "no"
#enable_octavia_driver_agent: "{{ enable_octavia | bool and neutron_plugin_agent == 'ovn' }}" #enable_octavia_driver_agent: "{{ enable_octavia | bool and neutron_plugin_agent == 'ovn' }}"
#enable_octavia_jobboard: "{{ enable_octavia | bool and 'amphora' in octavia_provider_drivers }}" #enable_octavia_jobboard: "{{ enable_octavia | bool and 'amphora' in octavia_provider_drivers }}"
#enable_opensearch: "{{ enable_central_logging | bool or enable_osprofiler | bool or (enable_cloudkitty | bool and cloudkitty_storage_backend == 'elasticsearch') }}" #enable_opensearch: "{{ enable_central_logging | bool or enable_osprofiler | bool or (enable_cloudkitty | bool and cloudkitty_storage_backend == 'opensearch') }}"
#enable_opensearch_dashboards: "{{ enable_opensearch | bool }}" #enable_opensearch_dashboards: "{{ enable_opensearch | bool }}"
#enable_opensearch_dashboards_external: "{{ enable_opensearch_dashboards | bool }}" #enable_opensearch_dashboards_external: "{{ enable_opensearch_dashboards | bool }}"
#enable_openvswitch: "{{ enable_neutron | bool and neutron_plugin_agent != 'linuxbridge' }}" #enable_openvswitch: "{{ enable_neutron | bool and neutron_plugin_agent != 'linuxbridge' }}"

View File

@ -0,0 +1,16 @@
---
features:
- |
Adds support for configuring CloudKitty to use OpenSearch as storage
backend.
upgrade:
- |
To use OpenSearch for CloudKitty storage, set
``cloudkitty_storage_backend`` to ``opensearch``. The following variables
have been added and may need to be updated unless the default configuration
is used:
* ``cloudkitty_opensearch_index_name``
* ``cloudkitty_opensearch_url``
* ``cloudkitty_opensearch_cafile``
* ``cloudkitty_opensearch_insecure_connections``