使用senlin资源进行自动伸缩管理

启动板蓝图的URL

https://blueprints.launchpad.net/tacker/+spec/autoscaling-management-with-senlin-resource

本规范引入了一种管理VDU自动伸缩功能的新方法。

问题描述

Tacker提供了管理VNF的可行功能,包括自动伸缩。目前,自动伸缩功能由Heat AutoScalingGroup提供。但Heat AutoScalingGroup对于VDU自动伸缩的支持不够完善。这是因为Heat只能向VDU集群发出自动伸缩指令,但缺乏管理VDU集群的能力。例如,当VDU自动伸缩失败或VDU进入ERROR状态时,恢复它的唯一方法是使用Heat stack-update,但stack-update通常恢复堆栈的可能性较低。Senlin[1]是一个OpenStack项目,它提供了集群服务。它定义了Profile、Cluster、Node、Policy、Receiver等概念,这些概念非常适合Tacker中的VDU集群管理用例。例如,当自动伸缩失败时,用户可以使用Senlin命令直接删除失败的节点。Senlin提供了强大的策略(放置策略、删除策略等),可以用来使VDU自动伸缩比Heat自动伸缩组更智能。如果用户想缩小集群,senlin删除策略(稍后可以添加到tacker)可以决定首先删除哪些节点(较老的节点或较新的节点),并且处于ERROR状态的节点将始终首先被删除。对于告警管理,Senlin不仅支持Ceilometer,还支持消息服务(Zaqar),甚至用户自己定义的其他监控工具,只要这些工具支持webhook。除了伸缩功能外,Senlin还提供了HA策略(未来将引入Tacker),可用于支持VDUs的HA功能。通过使用senlin来管理VDU集群,VDU集群的健康状态始终由senlin检查,如果集群不健康,例如,某些节点进入错误状态,senlin将发送事件通知用户。总而言之,将Senlin集成到Tacker中以管理VDU集群是合理的。

拟议的变更

要使用Senlin,首先需要通过Heat创建必要的Senlin实体,如Profile、Cluster、Policies等。所有Senlin资源已经在HOT模板中定义。通过将Senlin与tacker集成,在所有Tacker资源转换为HOT模板文件后,HOT文件将存储在Senlin profile中,然后Senlin会将此模板传递给Heat以创建VDU、CP VL等。整个流程如下:

                                                +-----------------+
+-----------------+                             |   HOT template  |
| TOSCA template  |                             | Senlin resource |
| Senlin scaling  |                             +-----------------+
| policy resource |     +-----------------+
|  + other Tacker | --> | Heat translator | -->          +            -->
|   resource      |     +-----------------+     +-----------------+      |
+-----------------+                             |   HOT template  |      |
                                                | Tacker resource |      |
                                                +-----------------+      |
      +----------------+                        +----------------------+ |
      | Senlin Cluster |           +------+     |    HOT Senlin        | |
      +----------------+      <--  | Heat | <-- | profile: Tacker.yaml | |
              ^                    +------+     +------------^---------+ |
              |                                              |       <---+
        +-------------+                         +-----------------+
        | Senlin node |                         |   HOT template  |
        |   VDU       |                         | Tacker resource |
        +-------------+                         +-----------------+

由于Tacker支持TOSCA格式模板,因此有必要在一个TOSCA模板中定义所有资源(Tacker和Senlin资源)。然后,TOSCA模板将由tosca-parser和heat-translator转换为HOT模板,该模板将用于部署VDU集群。Heat-translator已经支持了Tacker和Senlin的大部分资源转换,因此需要做的是TOSCA模板的集成,以及在heat-translator中添加一些资源的转换支持。并且在Tacker中,还需要完成一些额外的任务,例如解析VDU的监控属性。

VDU自动伸缩管理的TOSCA模板示例

tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0

description: Demo example

metadata:
  template_name: sample-tosca-vnfd

topology_template:
  node_templates:

    VDU1:
      type: tosca.nodes.nfv.VDU.Tacker
      properties:
        image: cirros-0.3.4-x86_64-uec
        flavor: m1.tiny
        availability_zone: nova
        metadata: {metering.vnf: SG1}
        monitoring_policy:
          name: ping
          parameters:
            monitoring_delay: 45
            count: 3
            interval: 1
            timeout: 2
          actions:
            failure: respawn

    CP1:
      type: tosca.nodes.nfv.CP.Tacker
      properties:
        management: true
        anti_spoofing_protection: false
      requirements:
        - virtualLink:
            node: VL1
        - virtualBinding:
            node: VDU1

    VL1:
      type: tosca.nodes.nfv.VL
      properties:
        network_name: net1
        vendor: Tacker

  policies:
    - cluster_scaling:
      type: tosca.policies.Tacker.Scaling
      description: Cluster node autoscaling
      driver: Senlin(Or some name else to distinguish Heat driver)
      targets: [VDU1]
      properties:
        min_instances: 2
        max_instances: 10
        default_instances: 3
        increment: 1

    - vdu_cpu_usage_monitoring_policy:
          type: tosca.policies.tacker.Alarming
          triggers:
              vdu_hcpu_usage_scaling_out:
                  event_type:
                      type: tosca.events.resource.cpu.utilization
                      implementation: Ceilometer
                  metrics: cpu_util
                  condition:
                      threshold: 50
                      constraint: utilization greater_than 50%
                      period: 60
                      evaluations: 1
                      method: avg
                      comparison_operator: gt
                  metadata: SG1
                  actions: [cluster_scaling]

上面的TOSCA模板没有引入新的资源类型,只有策略资源的一些属性与Tacker现在支持的现有伸缩策略不同。添加了‘driver’属性以区分Heat-autoscaling-group驱动程序和Senlin驱动程序。用户可以通过配置不同的驱动程序来切换自动伸缩后端。此TOSCA模板将被转换为HOT模板。转换后将创建两个HOT模板。一个包含所有与VDU相关的资源,就像Tacker现在所做的那样。当Heat创建Senlin资源时,Senlin profile将引用此HOT模板。另一个HOT模板仅包含senlin相关的资源,这些资源将首先传递给Heat进行资源创建。在Senlin资源‘profile’和‘cluster’创建之后,将根据senlin profile中的cluster属性desired_capacity(第196行)创建三个senlin节点。senlin节点实际上是VDU,它将在节点创建期间创建。之后,VDU节点属于一个集群。有一个receiver,它是一个指向集群的webhook,如果资源使用量触发告警限制,webhook将被执行以开始伸缩VDU集群。伸缩遵循附加到集群的伸缩策略。

Senlin资源的HOT模板

heat_template_version: 2016-04-08

description: >
  This template demonstrates creation of senlin resources for vm auto-scaling

resources:
  Senlin:
    type: OS::Senlin::Profile
    properties:
      type: os.nova.server-1.0
      properties:
        template: tacker.yaml

  Senlin_cluster:
    type: OS::Senlin::Cluster
    properties:
      desired_capacity: 3
      min_size: 2
      max_size: 10
      profile: {get_resource: Senlin}

  Senlin_scale_out_receiver:
    type: OS::Senlin::Receiver
    properties:
      action: CLUSTER_SCALE_OUT
      type: webhook
      cluster: {get_resource: Senlin_cluster}

  cluster_scaling_scale_out:
    type: OS::Senlin::Policy
    properties:
      type: senlin.policy.scaling-1.0
      bindings:
        - cluster: {get_resource: Senlin_cluster}
      properties:
        event: CLUSTER_SCALE_OUT
        adjustment:
          type: CHANGE_IN_CAPACITY
          number: 1

  scale_out_alarm:
    type: OS::Aodh::Alarm
    properties:
      meter_name: cpu_util
      statistic: avg
      period: 60
      evaluation_periods: 1
      threshold: 50
      repeat_actions: True
      alarm_actions:
        - {get_attr: [Senlin_scale_out_receiver, channel, alarm_url]}
      comparison_operator: gt

  Senlin_scale_in_receiver:
    type: OS::Senlin::Receiver
    properties:
      action: CLUSTER_SCALE_IN
      type: webhook
      cluster: {get_resource: Senlin_cluster}

  cluster_scaling_scale_in:
    type: OS::Senlin::Policy
    properties:
      type: senlin.policy.scaling-1.0
      bindings:
        - cluster: {get_resource: Senlin_cluster}
      properties:
        event: CLUSTER_SCALE_IN
        adjustment:
          type: CHANGE_IN_CAPACITY
          number: 1

  scale_in_alarm:
    type: OS::Aodh::Alarm
    properties:
      meter_name: cpu_util
      statistic: avg
      period: 60
      evaluation_periods: 1
      threshold: 50
      repeat_actions: True
      alarm_actions:
        - {get_attr: [Senlin_scale_in_receiver, channel, alarm_url]}
      comparison_operator: lt

VDU的HOT模板

heat_template_version: 2016-04-08

description: >
  This template demonstrates a template for VDU

resources:
  VDU:
    type: OS::Nova::Server
    properties:
      image: cirros-0.3.4-x86_64-uec
      flavor: m1.tiny
      availability_zone: nova
      networks:
        - network: net1

那么伸缩功能是如何工作的呢?以这个模板为例,在Heat部署了所有Senlin资源(一个在其上创建了三个VDU的集群、一个附加到集群的receiver和伸缩策略,以及一个告警)之后,伸缩管理可以完全交给Senlin。VDU可以根据资源消耗,在伸缩策略的规则下自动创建和删除。如果用户不想自动伸缩VDU,他们也可以使用‘tacker vnf-scale’命令手动控制可伸缩性。该请求将触发senlin后端执行伸缩操作。如果用户想自动伸缩选择性的VDU,他们只需将这些VDU信息添加到模板中,Senlin将采用这些节点到Senlin的集群,然后控制可伸缩性。Senlin团队目前正在实施此功能[2]。

API影响

此功能对Tacker的现有功能没有影响。管理VDU可伸缩性的现有方法可以像往常一样使用。此功能只是为VDU自动伸缩添加了一个新的选项。

所需依赖项

必须安装Senlin才能使此功能正常工作,因此有必要更新tacker的Devstack安装过程中的脚本和手动安装指南。由于Senlin资源由Heat使用senlinclient部署,并且用户可能还想使用senlin命令手动进行伸缩,因此需要senlinclient。并且senlinclient通过openstackSDK与其它客户端(Novaclient、Heatclient)通信,因此也需要安装openstackSDK。

实现

负责人

主要负责人

xuhaiwei<hai-xu@xr.jp.nec.com> xuan0802<thespring1989@gmail.com> Xinhui Li<lxinhui@vmware.com>

工作项

  • 在TOSCA模板中实现VDU的Senlin伸缩策略。

  • 更新Devstack安装过程和手动安装指南。

  • 添加单元测试和功能测试,用于伸缩功能。

  • 添加指南,说明如何使用Senlin伸缩功能。

测试

  • 添加VNF自动伸缩的功能测试。

  • 添加基于Senlin的自动伸缩的tosca模板示例。

文档影响

更新VNF自动伸缩的文档并添加新的文档。

参考资料

..[1] https://wiki.openstack.org/wiki/Senlin ..[2] https://blueprints.launchpad.net/senlin/+spec/senlin-adopt-function