【openstack】cloudkitty组件,入门级安装(快速)

@TOC

前言

什么是CloudKitty?
CloudKitty是OpenStack等的评级即服务项目。该项目旨在成为云的退款和评级的通用解决方案。从历史上看,它只能在OpenStack上下文中运行它,但现在可以在独立模式下运行CloudKitty。

CloudKitty允许进行基于指标的评级:它轮询终端节点以检索有关特定指标的度量值和元数据,将评级规则应用于收集的数据,并将评级数据推送到其存储后端。

CloudKitty是高度模块化的,这使得添加新功能变得容易。

架构

CloudKitty可以分为四大部分:

  • Data retrieval (API) 数据检索
  • Data collection (cloudkitty-processor) 数据收集
  • Data rating 数据评级
  • Data storage 数据存储

这些部分由两个进程处理:和 。数据检索部分由进程处理,其他部分由 处理。cloudkitty-apicloudkitty-processorcloudkitty-apicloudkitty-processor

以下是 CloudKitty 架构的概述:


image.png

安装

yum install openstack-cloudkitty-api openstack-cloudkitty-processor openstack-cloudkitty-ui

配置

编辑/etc/cloudkitty/cloudkitty.conf以配置 CloudKitty

[DEFAULT]
verbose = True
log_dir = /var/log/cloudkitty

[oslo_messaging_rabbit]
rabbit_userid = openstack
rabbit_password = RABBIT_PASSWORD
rabbit_hosts = RABBIT_HOST

[auth]
username = cloudkitty
password = CK_PASSWORD
tenant = service
region = RegionOne
url = http://localhost:5000/v2.0

[keystone_authtoken]
username = cloudkitty
password = CK_PASSWORD
project_name = service
region = RegionOne
auth_url = http://localhost:5000/v2.0
auth_plugin = password

[database]
connection = mysql://cloudkitty:CK_DBPASS@localhost/cloudkitty

[keystone_fetcher]
username = admin
password = ADMIN_PASSWORD
tenant = admin
region = RegionOne
url = http://localhost:5000/v2.0

[ceilometer_collector]
username = cloudkitty
password = CK_PASSWORD
tenant = service
region = RegionOne
url = http://localhost:5000

设置数据库和存储后端

[root@controller ~]# mysql -uroot -p000000
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 374
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE cloudkitty;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cloudkitty.* TO 'cloudkitty'@'localhost' IDENTIFIED BY '000000';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cloudkitty.* TO 'cloudkitty'@'%' IDENTIFIED BY '000000';
Query OK, 0 rows affected (0.00 sec)

运行数据库同步脚本

[root@controller ~]# cloudkitty-dbsync upgrade
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 464e951dc3b8, Initial migration
INFO  [alembic.runtime.migration] Running upgrade 464e951dc3b8 -> 2ac2217dcbd9, Added support for meta collector
INFO  [alembic.runtime.migration] Running upgrade 2ac2217dcbd9 -> 385e33fef139, Added priority to modules_state.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 3dd7e13527f3, Initial migration
INFO  [alembic.runtime.migration] Running upgrade 3dd7e13527f3 -> 4fa888fd7eda, Added threshold support.
INFO  [alembic.runtime.migration] Running upgrade 4fa888fd7eda -> 54cc17accf2c, Fixed constraint name.
INFO  [alembic.runtime.migration] Running upgrade 54cc17accf2c -> 10d2738b67df, Rename mapping table to hashmap_mappings.
INFO  [alembic.runtime.migration] Running upgrade 10d2738b67df -> f8c799db4aa0, Fix unnamed constraints.
INFO  [alembic.runtime.migration] Running upgrade f8c799db4aa0 -> c88a06b1cfce, Clean hashmap fields constraints.
/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py:507: Warning: Duplicate index `uniq_field_per_service`. This is deprecated and will be disallowed in a future release.
  cursor.execute(statement, parameters)
INFO  [alembic.runtime.migration] Running upgrade c88a06b1cfce -> 4da82e1c11c8, Add per tenant hashmap support
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 4f9efa4601c0, Initial migration.

初始化存储后端

[root@controller ~]# cloudkitty-storage-init
No handlers could be found for logger "cloudkitty.utils"
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 17fd1b237aa3, Initial migration
INFO  [alembic.runtime.migration] Running upgrade 17fd1b237aa3 -> 792b438b663, added tenant informations
INFO  [alembic.runtime.migration] Running upgrade 792b438b663 -> 307430ab38bc, improve qty precision
INFO  [alembic.runtime.migration] Running upgrade 307430ab38bc -> c703a1bad612, improve_qty_digit

CloudKitty 使用 Keystone 进行身份验证,并提供rating服务。

[root@controller ~]# openstack user create --domain demo --password 000000 cloudkitty
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | d5db5c4ee4a14492b69408f63107d11f |
| enabled             | True                             |
| id                  | f1dea9309b834edba3aa4c1b8607dc16 |
| name                | cloudkitty                       |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
[root@controller ~]# openstack role add --project service --user cloudkitty admin

对于应由 CloudKitty处理的每个租户,将rating角色赋予 cloudkitty :

[root@controller ~]# openstack role create rating
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | ee01d36a397b4b0ebcb579044c32a73c |
| name      | rating                           |
+-----------+----------------------------------+

创建rating服务及其端点:

[root@controller ~]# openstack service create --name cloudkitty --description "OpenStack rating" rating
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack rating                 |
| enabled     | True                             |
| id          | 78f3d51cf74843cd8d325b790e0c2b1c |
| name        | cloudkitty                       |
| type        | rating                           |
+-------------+----------------------------------+
openstack endpoint create --region RegionOne rating public http://controller:9292
openstack endpoint create --region RegionOne rating internal http://controller:9292
openstack endpoint create --region RegionOne rating admin http://controller:9292
[root@controller ~]# openstack endpoint create --region RegionOne rating public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 48b75b9d2d764b56a5bee00ff75b03b1 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 78f3d51cf74843cd8d325b790e0c2b1c |
| service_name | cloudkitty                       |
| service_type | rating                           |
| url          | http://controller:9292           |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne rating internal http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | b4f7fffa539441a68506db90b3ae89ce |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 78f3d51cf74843cd8d325b790e0c2b1c |
| service_name | cloudkitty                       |
| service_type | rating                           |
| url          | http://controller:9292           |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne rating admin http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | a607a077f119417d9e650c16dcd61f10 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 78f3d51cf74843cd8d325b790e0c2b1c |
| service_name | cloudkitty                       |
| service_type | rating                           |
| url          | http://controller:9292           |
+--------------+----------------------------------+

启动

[root@controller ~]# systemctl start cloudkitty-processor.service
[root@controller ~]# cloudkitty-api -p 8889  #临时启动API
No handlers could be found for logger "cloudkitty.utils"
/usr/lib/python2.7/site-packages/pecan/__init__.py:122: RuntimeWarning: `static_root` is only used when `debug` is True, ignoring
  RuntimeWarning
********************************************************************************
STARTING test server cloudkitty.api.app.build_wsgi_app
Available at http://controller:8889/
DANGER! For testing only, do not use in production
********************************************************************************
192.168.200.1 - - [29/Apr/2022 15:06:41] "GET / HTTP/1.1" 200 209

检索并安装 CloudKitty 的仪表板

git clone https://opendev.org/openstack/cloudkitty-dashboard.git

python setup.py install
yum install -y wget
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum -y install python-pip
PY_PACKAGES_PATH=`pip --version | cut -d' ' -f4`
ln -s $PY_PACKAGES_PATH/cloudkittydashboard/enabled/_[0-9]*.py /usr/share/openstack-dashboard/openstack_dashboard/enabled/
[root@controller bin]# systemctl restart httpd.service memcached.service
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,445评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,889评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,047评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,760评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,745评论 5 367
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,638评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,011评论 3 398
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,669评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,923评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,655评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,740评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,406评论 4 320
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,995评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,961评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,197评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,023评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,483评论 2 342

推荐阅读更多精彩内容