如何在openstack上使用现有环境附加一个浮动IP

How to attach a floating IP using the present environment on openstack

我是 openstack heat 文件的新手。我确实进行了搜索,但没有找到与我的问题相关的答案。这是我的模板热 yaml 文件:

heat_template_version: newton

description: Simple template to deploy a single compute instance with an attached volume

resources:   
   my_instance:
    type: OS::Nova::Server
    properties:
      name: instance-name
      flavor: std.cpu1ram1
      block_device_mapping_v2:
        - device_name: vda
          image: RHEL-7.4
          volume_size: 30
          delete_on_termination: true
      networks:
        - network: network-name.admin-network
      security_group: 
        - security_group: [security-name.group-sec-default]

  my_volume:
    type: OS::Cinder::Volume
    properties:
      size: 10

  my_attachment:
      type: OS::Cinder::VolumeAttachment
      properties:
        instance_uuid:  { get_resource: my_instance }
        volume_id: { get_resource: my_volume }
        mountpoint: /dev/vdb

这个 heat 文件有效,但我不知道如何将浮动 IP 附加到 "my_instance"。我能够在 Horizo​​n 中完成它并且它在没有 PB 的情况下工作。在 Horizo​​n 界面下,我必须选择 "Router_dmz" 作为创建并允许浮动 IP 的池。据我了解,浮动 IP 地址应该关联到 "network-name.admin-network"。我阅读了很多文档,但我不知道我是否必须使用 OS:Neutron::FloatingIPAssociation 资源或 OS::Nova::FloatingIPAssociation。我试过在我这边,我没有问题。

我发现这对我有用:

heat_template_version: newton

description: Simple template to deploy a single compute instance 

resources:
  floating_ip:
    type: OS::Nova::FloatingIP
    properties:
      pool: string_of_pool_of_public_network

  my_instance:
    type: OS::Nova::Server
    properties:
      name: instance-name
      flavor: std.cpu1ram1
      block_device_mapping_v2:
        - device_name: vda
          image: RHEL-7.4
          volume_size: 30
          delete_on_termination: true
      networks:
        - network: network-name.admin-network
      security_group: 
        - security_group: [security-name.group-sec-default]

  association:
    type: OS::Nova::FloatingIPAssociation
    properties:
      floating_ip: { get_resource: floating_ip }
      server_id: { get_resource: my_instance }

但这个解决方案已被弃用我对 Neutron 没有任何问题