欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Play with Tacker(by quqi99)

程序员文章站 2022-07-11 11:41:45
...

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 (http://blog.csdn.net/quqi99)

Install via devstack

#Enable tacker
BRANCH=master
enable_plugin heat https://git.openstack.org/openstack/heat $BRANCH
enable_plugin networking-sfc https://git.openstack.org/openstack/networking-sfc $BRANCH
enable_plugin barbican https://git.openstack.org/openstack/barbican $BRANCH
enable_plugin mistral https://git.openstack.org/openstack/mistral $BRANCH
enable_plugin tacker https://git.openstack.org/openstack/tacker $BRANCH
source openrc
export OS_USERNAME=admin
$ env |grep OS_
OS_PROJECT_DOMAIN_ID=default
OS_REGION_NAME=RegionOne
OS_USER_DOMAIN_ID=default
OS_PROJECT_NAME=demo
OS_IDENTITY_API_VERSION=3
OS_PASSWORD=password
OS_AUTH_TYPE=password
OS_AUTH_URL=http://172.16.1.1/identity
OS_USERNAME=admin
OS_TENANT_NAME=demo
OS_VOLUME_API_VERSION=2

Devstack会自动配置下列镜像与网络:

wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public
$ glance image-list
+--------------------------------------+--------------------------+
| ID                                   | Name                     |
+--------------------------------------+--------------------------+
| 55444fe2-4b26-4908-ba1b-4c5e95bd0b83 | cirros-0.3.5-x86_64-disk |
| 26e711a9-d5c8-4991-a81d-5ebf5d2724d1 | OpenWRT                  |
+--------------------------------------+--------------------------+

$ neutron net-list
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+----------+----------------------------------+-------------------------------------------------------+
| id                                   | name     | tenant_id                        | subnets                                               |
+--------------------------------------+----------+----------------------------------+-------------------------------------------------------+
| 43f2cbec-367c-45e8-bf37-26e66366b9eb | private  | 1e99096c578a4b2786c6a44ffd6bed44 | ab7d15c8-03d5-429a-926f-2ba07d0fb77f 10.0.0.0/26      |
| 57c739b9-6e61-4795-a72f-29d9f3ee5ab2 | net0     | b9c12c1af30349b987fe9ab638659e48 | ab177e6d-94ea-4d93-bbc6-d9e4c2bba90e 10.10.0.0/24     |
| 5c6dc85e-9fd0-49f6-8fc2-3386709b4a09 | net_mgmt | b9c12c1af30349b987fe9ab638659e48 | 7525b4e6-1bff-4b68-a2c6-d5633a155a7f 192.168.120.0/24 |
| 63d88cd7-d540-446d-9538-4676b30cb494 | public   | b9c12c1af30349b987fe9ab638659e48 | 7a2873fc-607b-4f9e-bd94-7ed91a746553 192.168.101.0/24 |
| 95717e35-d3bc-4c6a-937c-b47c566a3666 | net1     | b9c12c1af30349b987fe9ab638659e48 | 0ecbc79b-c103-464f-ad59-2c7733c43e39 10.10.1.0/24     |
+--------------------------------------+----------+----------------------------------+-------------------------------------------------------+

概念与步骤

Tacker中有这些概念:

  • VIM: 相当于OpenStack
  • VNFD: VNF Descriptor
  • VNF: Virtual Network Function
    所以依次需要:
  • 创建VIM
cat > vim_config.yaml << EOF
auth_url: 'http://172.16.1.1/identity'
username: 'nfv_user'
password: 'devstack'
project_name: 'nfv'
project_domain_name: 'Default'
user_domain_name: 'Default'
EOF
tacker vim-register --is-default --config-file vim_config.yaml test-vim
  • 创建vnfd
tacker vnfd-create --vnfd-file ./sample-vnfd.yaml sample-vnfd
tacker vnfd-list
  • 创建vnf
tacker vnf-create --vnfd-name sample-vnfd sample-vnf

TOSCA VNFD语法

VNFD和juju的yaml类似, 语法见下面sample-vnfd.yaml中的注释:

$ cat sample-vnfd.yaml 
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
  template_name: sample-tosca-vnfd
topology_template:
  # VDU1 represents a node provided by underlying VIM
  node_templates:
    VDU1:
      type: tosca.nodes.nfv.VDU.Tacker
      # Define flavor
      capabilities:
        nfv_compute:
          properties:
            num_cpus: 1
            mem_size: 512 MB
            disk_size: 1 GB
      # Define image
      properties:
        image: cirros-0.3.5-x86_64-disk
        availability_zone: nova
        # Tacker has two integrated mgmt_driver to configure metadata - noop and openwrt
        mgmt_driver: noop
        config: |
          param0: key1
          param1: key2
    # CP (Connection Point) represents a neutron port, CP1 is the name of this port
    CP1:
      type: tosca.nodes.nfv.CP.Tacker
      properties:
        management: true
        order: 0
        anti_spoofing_protection: false
      # One side of this CP is connecting to VL1, another side is connection to VDU1 
      requirements:
        - virtualLink:
            node: VL1
        - virtualBinding:
            node: VDU1
    # VL (Virtual Link) represents a neutron network
    VL1:
      type: tosca.nodes.nfv.VL
      properties:
        network_name: net_mgmt
        vendor: Tacker

VNFD的语法结构图如下:
Play with Tacker(by quqi99)

Tacker如何实现水平伸缩

需有水平伸缩相关的配置:

  # 定义策略,此节点与node_templates同级
  policies:
    # 此处定义了一个scale策略;SP1为自定义的名字
    - SP1:
        # scale策略的type
        type: tosca.policy.tacker.Scaling
        # 定义了策略的详细内容
        properties:
          # 每次伸缩的数量
          increment: 1
          # 下一次操作的冷却时间
          cooldown: 0
          # 总量的下限
          min_instances: 1
          # 总量的上限
          max_instances: 3
          # 初始的数量
          default_instances: 2
          # 要伸缩的目标,vdu、cp均可伸缩
          targets: [VDU1]

然后运行下列命令进行伸缩:

tacker vnf-scale --vnf-name test_vnf --scaling-policy-name SP1 --scaling-type out  

上面伸缩配置和创建vim的配置一样会由Tacker最终转换为Heat模板,Heat模板最终再调用Neutron LBaaS v2来实现HA。点击这见我的另一博客
而Juju的水平扩展则更为简单,直接运行如“juju add-unit nova-compute”之类的命令为自动增加节点,并且在这些节点之间添加haproxy+corosync的HA服务,点击这见我的另一博客
如此说来,还是juju好用。

mgmt_driver

可以将一段脚本通过config参给VIM,然后tacker再ssh进这个VIM来执行这段配置。
这块juju则是直接ssh进VIM后自己该干嘛干嘛,灵活性更高。

Reference

[1] https://docs.openstack.org/tacker/latest/
[2] http://blog.csdn.net/tpiperatgod/article/details/56282617
[3] https://www.ibm.com/developerworks/cn/cloud/library/1511_zoupx_openstackheat/index.html
[4] https://www.ibm.com/developerworks/cn/cloud/library/cl-cloud-orchestration-technologies-trs/index.html

相关标签: tacker vim