Fujitsu K5 – Deploying a Simple Stack with Floating IP Assignment

Here we have another example of deploying a simple virtual machine with a floating ip address. The prerequisites for this stack are an existing router that is connected to the external network as can be seen below:

SimpleStackPrerequisites.PNG

And the ID of the external network that the router has been connected to:

simplestackprerequisites2

Amend the input parameters of the stack to align with your environment and then it’s just business as usual – load and submit the stack.

simplestackprerequisites3

heat_template_version: 2013-05-23
# Author: Graham Land
# Date: 13/10/2016
# Purpose: Simple template to demonstrate the basic format/usage of HOT stacks on our K5 platform
description: Demo K5 template to build a private network, subnet, and instance with a global ip address – router and external network are prerequisites
# Input parameters
parameters:
image:
type: string
label: Image name or ID
description: Image to be used for compute instance
default: "Ubuntu Server 14.04 LTS (English) 01"
flavor:
type: string
label: Flavor
description: Type of instance (flavor) to be used
default: "S-1"
key:
type: string
label: Key name
description: Name of key-pair to be used for compute instance
default: "demostack"
public_net:
type: string
label: external network ID
description: Public network
default: "d730db50-0e0c-4790-9972-1f6e2b8c4915"
private_net_name:
type: string
label: Private network name or ID
description: Network to attach instance to.
default: "hello-net"
private_net_cidr:
type: string
label: Private network name or ID
description: Network to attach instance to.
default: "192.168.2.0/24"
az:
type: string
label: Availability Zone
description: Region AZ to use
default: "uk-1b"
ext_router:
type: string
label: External Router
description: Router with external access for global ip allocation
default: "d643d348-7ae0-45a3-a375-54ce9d8803f7"
# K5 Infrastructure resources to be built
resources:
# Create a new private network
private_net:
type: OS::Neutron::Net
properties:
availability_zone: { get_param: az }
name: { get_param: private_net_name }
# Create a new subnet on the private network
private_subnet:
type: OS::Neutron::Subnet
depends_on: private_net
properties:
availability_zone: { get_param: az }
name: subnet
network_id: { get_resource: private_net }
cidr: { get_param: private_net_cidr }
dns_nameservers:
8.8.8.8
# Connect an interface on the private network's subnet to the router
router_interface:
type: OS::Neutron::RouterInterface
properties:
router_id: { get_param: ext_router }
subnet_id: { get_resource: private_subnet }
# Create a new port for the server interface, assign an ip address and security group
server1_port:
type: OS::Neutron::Port
depends_on: [ router_interface,server_security_group ]
properties:
availability_zone: { get_param: az }
network_id: { get_resource: private_net }
security_groups: [{ get_resource: server_security_group }]
# Allocate a floating/global ip address
server1_floating_ip:
type: OS::Neutron::FloatingIP
depends_on: [router_interface]
properties:
availability_zone: { get_param: az }
floating_network_id: { get_param: public_net }
# Assign a floating/global ip address to the fixed server ip address
server1_floating_ip_association:
type: OS::Neutron::FloatingIPAssociation
depends_on: server1_floating_ip
properties:
floatingip_id: { get_resource: server1_floating_ip }
port_id: { get_resource: server1_port }
# Create a security group
server_security_group:
type: OS::Neutron::SecurityGroup
properties:
description: Add security group rules for server
name: hello-security-group
rules:
remote_ip_prefix: 0.0.0.0/0
protocol: tcp
port_range_min: 22
port_range_max: 22
remote_ip_prefix: 0.0.0.0/0
protocol: tcp
port_range_min: 80
port_range_max: 80
remote_ip_prefix: 0.0.0.0/0
protocol: tcp
port_range_min: 443
port_range_max: 443
remote_ip_prefix: 0.0.0.0/0
protocol: icmp
# Create a system volume for use with the server
sys-vol:
type: OS::Cinder::Volume
properties:
availability_zone: { get_param: az }
name: "boot-vol"
size: 30
volume_type: "M1"
image : { get_param: image }
# Build a server using the system volume defined above
server:
type: OS::Nova::Server
depends_on: [ server1_port,server1_floating_ip ]
properties:
key_name: { get_param: key }
image: { get_param: image }
flavor: { get_param: flavor }
admin_user: ubuntu
block_device_mapping: [{"volume_size": "30", "volume_id": {get_resource: sys-vol}, "delete_on_termination": True, "device_name": "/dev/vda"}]
name: "helloVM1"
networks:
port: { get_resource: server1_port }
# Define values to be returned following a successful stack build
outputs:
server_private_ip:
description: IP address of server on private network
value: { get_attr: [ server, first_address ] }
server1_public_ip:
description: Floating IP address of server1 in public network
value: { get_attr: [ server1_floating_ip, floating_ip_address ] }

view raw
SimpleStack.yml
hosted with ❤ by GitHub

And you should end up with something like this:

simplestackprerequisites4

Happy Stacking!

 

3 thoughts on “Fujitsu K5 – Deploying a Simple Stack with Floating IP Assignment

  1. Thanks Graham for the stack template example to get me started. I just noticed one further prerequisites to create a Key Pair before I could deploy this stack. Other than that it is very straightforward.

    Like

  2. Nice ,but as per the requirement we want to create VM in existing Network ,Subnet and allocate public IP for the created VM .

    Like

    1. Hi

      The following is an example that uses an existing tenant network that is connected to the external network via a router.

      heat_template_version: 2013-05-23
      # Author: Graham Land
      # Date: 10/11/2016
      # Purpose: Demonstrate deployment of a Linux box with Global IP to an existing Network on K5
      description: >
      HOT template to deploy a server into an existing neutron tenant network and
      assign a floating IP addresses to the server so it is routable from the
      public network. Fujitsu K5 OpenStack IaaS Public Cloud
      parameters:
      key_name:
      type: string
      label: Key name
      description: Name of keypair to assign to servers "Alexa_KP""demostack"
      default: "Alexa_KP"
      image:
      type: string
      label: Image name or ID
      description: Image to be used for compute instance
      default: "Ubuntu Server 14.04 LTS (English) 01"
      flavor:
      type: string
      label: Flavor
      description: Type of instance (flavor) to be used
      default: "S-1"
      public_net_id:
      type: string
      label: external network ID
      description: Public network
      default: "d730db50-0e0c-4790-9972-1f6e2b8c4915"
      private_net_id:
      type: string
      label: Private network name or ID
      description: ID of private network into which servers get deployed
      default: "d89a3835-046a-4c44-ad02-1b786e01176d"
      private_subnet_id:
      type: string
      label: Private sub network name or ID
      description: ID of private sub network into which servers get deployed
      default: "9ab91700-97df-42d2-a9c2-d57adb73158c"
      az:
      type: string
      label: Availability Zone
      description: Region AZ to use
      default: "uk-1b"
      resources:
      server1:
      type: OS::Nova::Server
      depends_on: [sys-vol]
      properties:
      admin_user: ubuntu
      block_device_mapping: [{"volume_size": "3", "volume_id": {get_resource: sys-vol}, "delete_on_termination": True, "device_name": "/dev/vda"}]
      name: "alexaVM"
      image: { get_param: image }
      flavor: { get_param: flavor }
      key_name: { get_param: key_name }
      networks:
      port: { get_resource: server1_port }
      server1_port:
      type: OS::Neutron::Port
      properties:
      availability_zone: { get_param: az }
      network_id: { get_param: private_net_id }
      fixed_ips:
      subnet_id: { get_param: private_subnet_id }
      security_groups: [{ get_resource: server_security_group }]
      server1_floating_ip:
      type: OS::Neutron::FloatingIP
      depends_on: [server1_port]
      properties:
      availability_zone: { get_param: az }
      floating_network_id: { get_param: public_net_id }
      server1_floating_ip_association:
      type: OS::Neutron::FloatingIPAssociation
      depends_on: server1_floating_ip
      properties:
      floatingip_id: { get_resource: server1_floating_ip }
      port_id: { get_resource: server1_port }
      server_security_group:
      type: OS::Neutron::SecurityGroup
      properties:
      description: Add security group rules for server
      name: security-group
      rules:
      remote_ip_prefix: 0.0.0.0/0
      protocol: tcp
      port_range_min: 22
      port_range_max: 22
      remote_ip_prefix: 0.0.0.0/0
      protocol: icmp
      sys-vol:
      type: OS::Cinder::Volume
      depends_on: [server_security_group]
      properties:
      availability_zone: { get_param: az }
      name: "boot-vol"
      size: 3
      volume_type: "M1"
      image : { get_param: image }
      outputs:
      server1_private_ip:
      description: IP address of server1 in private network
      value: { get_attr: [ server1, first_address ] }
      server1_public_ip:
      description: Floating IP address of server1 in public network
      value: { get_attr: [ server1_floating_ip, floating_ip_address ] }

      Keep up the great work!

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s