在热模板中为浮动IP分配负载均衡器

时间:2022-05-03 12:47:01

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.

有谁知道如何将浮动IP地址与热模板中的负载均衡器相关联?我可以在一个实例(或一堆实例,但从小开始)创建负载平衡器;并且可以将浮动IP地址与Horizo​​n中的负载均衡器相关联,但我无法弄清楚如何通过加热来实现。

1 个解决方案

#1


1  

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.

事实证明,OS :: Neutron :: Pool资源的vip属性包含的密钥多于此处记录的密钥。特别是,vip属性包含port_id,它是与此池关联的Neutron端口的地址。

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

由于我们有一个Neutron端口ID,我们可以使用它来关联一个浮动IP地址,如下所示:

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.

get_attr调用是获取池资源的vip属性的port_id属性。

#1


1  

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.

事实证明,OS :: Neutron :: Pool资源的vip属性包含的密钥多于此处记录的密钥。特别是,vip属性包含port_id,它是与此池关联的Neutron端口的地址。

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

由于我们有一个Neutron端口ID,我们可以使用它来关联一个浮动IP地址,如下所示:

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.

get_attr调用是获取池资源的vip属性的port_id属性。