简体   繁体   中英

Assigning a Floating IP to a Load Balancer in a heat template

Does anyone know how to associate a floating IP address with a load balancer in a heat template? I can create a load balancer on an instance (or a bunch of instances, but starting small) in heat; and can associate a floating IP address to the load balancer in Horizon, but I can't figure out how to do it through heat.

I just had to find the answer to this question myself.

It turns out that the vip attribute of an OS::Neutron::Pool resource contains a few more keys than are documented here . In particular, the vip attribute contains a port_id , which is the address of the Neutron port associated with this pool.

Since we have a Neutron port id, we can use that to associate a floating ip address like this:

type: "OS::Neutron::Pool"
  properties:
    protocol: HTTP
    monitors:
      - {get_resource: monitor}
    subnet_id: {get_resource: fixed_subnet}
    lb_method: ROUND_ROBIN
    vip:
      protocol_port: 80

lb_floating:
  type: "OS::Neutron::FloatingIP"
  properties:
    floating_network_id:
      get_param: external_network_id
    port_id:
      get_attr: [pool, vip, port_id]

That get_attr call is getting the port_id attribute of the vip attribute of the pool resource.

I had the same question in regard to Octavia rather then Neutron, however Larsks answer did point me in the right direction.

The OS::Octavia::LoadBalancer object has a vip_port_id attribute which can be accessed in the same way:

  port_id:
    get_attr: [lb1, vip_port_id]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM