挖掘Kubernetes 弹性伸缩:利用 KEDA实现基于事件驱动的自动缩放器( 二 )

测试上面的配置中我们以test表中的行数作为"事件",并且阈值为4
#select * from test;+----+------------+-----------+------------+-------------------+------+----------+| id | created_at | update_at | panel_name | link| icon | tag_name |+----+------------+-----------+------------+-------------------+------+----------+|6 | NULL| NULL| kubesre| www.kubesre.com/| ECS|||7 | NULL| NULL| kubesre| www.kubesre.com/| ECS|||8 | NULL| NULL| kubesre| www.kubesre.com/| ECS||+----+------------+-----------+------------+-------------------+------+----------+#添加数据mysql> INSERT INTO `test` VALUES (1, NULL, NULL, 'kubesre', 'www.kubesre.com/', 'ECS', '');Query OK, 1 row affected (0.01 sec)mysql> INSERT INTO `test` VALUES (2, NULL, NULL, 'kubesre', 'www.kubesre.com/', 'ECS', '');Query OK, 1 row affected (0.01 sec)mysql> INSERT INTO `test` VALUES (3, NULL, NULL, 'kubesre', 'www.kubesre.com/', 'ECS', '');Query OK, 1 row affected (0.00 sec)mysql> INSERT INTO `test` VALUES (4, NULL, NULL, 'kubesre', 'www.kubesre.com/', 'ECS', '');Query OK, 1 row affected (0.01 sec)mysql> INSERT INTO `test` VALUES (5, NULL, NULL, 'kubesre', 'www.kubesre.com/', 'ECS', 'Pod');Query OK, 1 row affected (0.00 sec)mysql> select * from test;+----+------------+-----------+------------+-------------------+------+----------+| id | created_at | update_at | panel_name | link| icon | tag_name |+----+------------+-----------+------------+-------------------+------+----------+|1 | NULL| NULL| kubesre| www.kubesre.com/| ECS|||2 | NULL| NULL| kubesre| www.kubesre.com/| ECS|||3 | NULL| NULL| kubesre| www.kubesre.com/| ECS|||4 | NULL| NULL| kubesre| www.kubesre.com/| ECS|||5 | NULL| NULL| kubesre| www.kubesre.com/| ECS| Pod||6 | NULL| NULL| kubesre| www.kubesre.com/| ECS|||7 | NULL| NULL| kubesre| www.kubesre.com/| ECS|||8 | NULL| NULL| kubesre| www.kubesre.com/| ECS||+----+------------+-----------+------------+-------------------+------+----------+# kubectl get hpa -n mysqlNAMEREFERENCETARGETSMINPODSMAXPODSREPLICASAGEkeda-hpa-mysql-scaledobjectstatefulset/mysql4/4 (avg)110024h56m# kubectl get po -n mysqlNAMEREADYSTATUSRESTARTSAGEmysql-01/1Running1 (5h45m ago)5h47mmysql-10/1Running055s由于我集群本身的原因,mysql-1 没有起来,但是我们看到了今天实验目的已经成功结论在本文中,我们利用KADA实现了基于事件的弹性伸缩,更加紧密的拥抱业务,基于服务的“事件”实现伸缩,使得伸缩更加合理,高效 。但事实上,针对像Mysql 这类有状态服务伸缩,如何实现伸缩过程中的数据一致性及可用性是需要各个服务需要考虑的问题,但我相信在不久的将来,有状态服务的伸缩也可以像现如今的无状态服务一样顺滑~

【挖掘Kubernetes 弹性伸缩:利用 KEDA实现基于事件驱动的自动缩放器】


推荐阅读