Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm newbie on openstack heat file. I did search but I didn't find relevant answer to my question. Here my template heat yaml file :

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

This heat file works but I don't know how to attach floating IP to "my_instance". I'm able to do it inside Horizon and it's working without PB. Under Horizon interface, I've to choose "Router_dmz" as a pool which creates and allows floating IP. As I understood the floating IP address should associated to "network-name.admin-network". I read many documentation, and I don't know if I've to use the OS:Neutron::FloatingIPAssociation resources or OS::Nova::FloatingIPAssociation. I tried on my side and I've no issue.

like image 735
dubis Avatar asked Oct 16 '22 14:10

dubis


1 Answers

I found this works for me :

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 }

But this solution is deprecated I don't have any issue with Neutron

like image 57
dubis Avatar answered Oct 21 '22 08:10

dubis