• Home
  • VPS Servers
  • Dedicated Server Slices
  • Shared Web Hosting
  • About Us
  • Support
  • Contact
  • Blog
  • Client Login
  • VM Admin
VPS City
  • Home
  • VPS Servers
  • Dedicated Server Slices
  • Shared Web Hosting
  • About Us
  • Support
  • Contact
  • Blog
  • Client Login
  • VM Admin

Openstack HEAT tutorials: 1. Deploying an instance with haproxy installed and configured for basic HTTP load balancing

May 29, 2015Gabriel MoldoveanuCloud Servers2 Comments

This is a an example of HEAT template for deploying an instance with haproxy installed and configured for basic HTTP load balancing.

Below you my see the script which is composed of three sections:

1. Template format section

This template is written AWS CloudFormation (CFN) format. This is typically expressed in JSON format. The template format and version are specified at the top of the template:
“AWSTemplateFormatVersion” : “2010-09-09″

2. Parameters section

Here we declare the input parameters that have to be provided when instantiating the template. In our case, the Input Parameters are the Glance image ID (image used for launching the instances), instance flavor, network ID, keypair and Security group. These are actually all the parameters required when manually launching an instance. Also, as you may see below, it’s possible to provide default values so that you won’t need to provide all the input parameters, each time.

3. Resources section

Next comes the Resources section where we define the templates for the actual resources that will make up a stack deployed from the HEAT template (e.g. compute instances, networks, storage volumes). In this example, we deploy a single instance and we install haproxy with a basic configuration. The bash script, which is nothing more than a guest customization script, is provided inside the “user data” property. There you may insert any script you like and it will be automatically launched, immediately after the instance instance is created and has network connectivity.

 

[code lang=”bash”] {
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Heat template for creating an instance with haproxy installed and configured for basic HTTP load balancing",
"Parameters": {
"Instance Image Id" : {
"Description" : "Image Id to be used when launching the instance",
"Type" : "String",
"Default" : "8e66f730-bbfe-4864-8e15-e5611f56cdb8"
},
"Instance Flavour" : {
"Description" : "Flavour to be used when launching the instance",
"Type" : "String",
"Default" : "m1.small"
},
"Network ID" : {
"Description" : "ID of Neutron network into which servers get deployed",
"Type" : "String",
"Default" : "d073e257-bbfb-41d9-af26-e78fea76b30f"
},
"KeyPair" : {
"Description" : "Keypair to be used when launching the instance",
"Type" : "String",
"Default" : "mbalas"
},
"SecurityGroup" : {
"Description" : "SecurityGroup to be used when launching the instance",
"Type" : "String",
"Default" : "MBA_securityGroup"
}
},
"Resources" : {
"Haproxy" : {
"Type" : "OS::Nova::Server",
"Properties" : {
"name" : "Haproxy",
"image" : {"Ref" : "Instance Image Id"},
"flavor": {"Ref" : "Instance Flavour"},
"networks": [{"network":{"Ref" : "Network ID"}}],
"key_name": {"Ref" : "KeyPair"},
"security_groups": [{"Ref" : "SecurityGroup"}, "default"],
"user_data_format": "RAW",
"user_data": { "Fn::Join" : ["", [
"#!/bin/bash -vn",
"apt-get -y updaten",
"apt-get -y install haproxyn",
"echo ENABLED=1 > /etc/default/haproxyn",
"cat << EOF >> /etc/haproxy/haproxy.cfgn",
"listen http-servern",
" bind *:80n",
" balance roundrobinn",
" mode httpn",
" option forwardforn",
" option httpchkn",
" option httpclosen",
" option httplogn",
" timeout client 3hn",
" timeout server 3hn",
" server Ubuntu1 10.100.0.164:80 check inter 2000 fall 3n",
" server Ubuntu2 10.100.0.165:80 check inter 2000 fall 3n",
"EOFn",
"service haproxy start"]] }
}
}
}
}
[/code]

How we launch the template and provide the input parameters:

From the Horizon interface, go to Project -> Orchestration -> Stacks -> Press + Launch stack -> Template source: File -> Template URL: provide the location of the script (from your local hard drive) -> Press Next and this screen will be shown to you:
HEAT-launch-screen

 

Here you just have to provide a Stack Name and the Input Paramaters (or leave the default values). Finally, press Launch.

Tags: haproxy,  heat,  load balancer,  OpenStack

Written by Gabriel Moldoveanu

Related Posts
  • Openstack Summit, Vancouver – Day 2 (May 2015)

2 thoughts on “Openstack HEAT tutorials: 1. Deploying an instance with haproxy installed and configured for basic HTTP load balancing”

  1. Pingback: Openstack HEAT tutorials: Autoscaling

  2. Pingback: Openstack HEAT tutorials: Autoscaling with Ceilometer

Leave a Reply

Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

← Openstack Summit, Vancouver – Day 2 (May 2015)
Openstack HEAT tutorials: 2. Creating multiple resources of the same type using autoscaling group →

Latest tweet

Invalid or expired token.

Recent Posts

  • The BMW MINI SP Daten v58 files
  • OpenSSH server – Enable and secure on Ubuntu 16.04 LTS
  • NodeJS install on Ubuntu 16.04 LTS (Xenial Xerus)
  • Google Straps Aclima Sensors To Street View Cars To Map Air Pollution
  • Why are smartwatches still a niche purchase?

VPS City Hosting

Address

Helsingborg, Skåne
Sweden

office@vps-city.com

https://www.vps-city.com

© Copyright - 2013-2017 : All Rights Reserved.
Powered by VPS City Hosting

Privacy Policy


Multi Domain SSLNetim Certified Partner

photo of




VPS City Hosting

office@vps-city.com

Videgatan

Helsingborg
,
Skane
,
25230

Sweden