Moving HAProxy-based LBaaS package to open-paas
Change-Id: If64d72a9a3d54b47d373a7e89ca4fc4e1bb84d93
This commit is contained in:
parent
4f8def5ca9
commit
6f18d58b35
53
murano-apps/haproxy-based-lbaas/Classes/HAProxy.yaml
Normal file
53
murano-apps/haproxy-based-lbaas/Classes/HAProxy.yaml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
Namespaces:
|
||||||
|
=: io.murano.apps.lbaas
|
||||||
|
std: io.murano
|
||||||
|
sys: io.murano.system
|
||||||
|
|
||||||
|
|
||||||
|
Name: HAProxy
|
||||||
|
|
||||||
|
Extends: =:LoadBalancer
|
||||||
|
|
||||||
|
Properties:
|
||||||
|
|
||||||
|
name:
|
||||||
|
Contract: $.string().notNull()
|
||||||
|
|
||||||
|
implementation:
|
||||||
|
Contract: $.string()
|
||||||
|
Default: haproxy
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
installLoadBalancer:
|
||||||
|
Body:
|
||||||
|
- $resources: new(sys:Resources)
|
||||||
|
- $template: $resources.yaml('DeployHAProxy.template')
|
||||||
|
- $.environment.reporter.report($this, 'Installing HAProxy')
|
||||||
|
- $.instance.agent.call($template, $resources)
|
||||||
|
- $.environment.reporter.report($this, 'HAProxy is installed.')
|
||||||
|
|
||||||
|
installLBaaS:
|
||||||
|
Body:
|
||||||
|
- $resources: new(sys:Resources)
|
||||||
|
- $template: $resources.yaml('DeployLBaaS.template').bind(dict(
|
||||||
|
impl => $.implementation
|
||||||
|
))
|
||||||
|
- $.environment.reporter.report($this, 'Installing LBaaS...')
|
||||||
|
- $.instance.agent.call($template, $resources)
|
||||||
|
- $.environment.reporter.report($this, 'LBaaS is installed and started.')
|
||||||
|
- Return:
|
||||||
|
port: 8993
|
||||||
|
path: /v1
|
||||||
|
|
75
murano-apps/haproxy-based-lbaas/Classes/LoadBalancer.yaml
Normal file
75
murano-apps/haproxy-based-lbaas/Classes/LoadBalancer.yaml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
Namespaces:
|
||||||
|
=: io.murano.apps.lbaas
|
||||||
|
std: io.murano
|
||||||
|
res: io.murano.resources
|
||||||
|
sys: io.murano.system
|
||||||
|
|
||||||
|
|
||||||
|
Name: LoadBalancer
|
||||||
|
|
||||||
|
Extends: std:Application
|
||||||
|
|
||||||
|
Properties:
|
||||||
|
|
||||||
|
name:
|
||||||
|
Contract: $.string().notNull()
|
||||||
|
|
||||||
|
instance:
|
||||||
|
Contract: $.class(res:Instance).notNull()
|
||||||
|
|
||||||
|
implementation:
|
||||||
|
Contract: $.string()
|
||||||
|
Default: null
|
||||||
|
Usage: Runtime
|
||||||
|
|
||||||
|
environment:
|
||||||
|
Contract: $.class(std:Environment)
|
||||||
|
Usage: Runtime
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
initialize:
|
||||||
|
Body:
|
||||||
|
- $.environment: $.find(std:Environment).require()
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
Body:
|
||||||
|
- If: $.getAttr(deployed, false)
|
||||||
|
Then:
|
||||||
|
Return: 0
|
||||||
|
|
||||||
|
- $.environment.reporter.report($this, 'Creating security groups...')
|
||||||
|
- $securityGroupIngress:
|
||||||
|
- ToPort: 65535
|
||||||
|
FromPort: 1
|
||||||
|
IpProtocol: tcp
|
||||||
|
External: true
|
||||||
|
- $.environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
||||||
|
- $.environment.reporter.report($this, 'Creating instance for load balancer...')
|
||||||
|
- $.instance.deploy()
|
||||||
|
- $.environment.reporter.report($this, 'Instance is created.')
|
||||||
|
- $resources: new(sys:Resources)
|
||||||
|
- $.installLoadBalancer()
|
||||||
|
- $lbaas: $.installLBaaS()
|
||||||
|
- If: $.instance.assignFloatingIp
|
||||||
|
Then:
|
||||||
|
- $host: $.instance.floatingIpAddress
|
||||||
|
Else:
|
||||||
|
- $host: $.instance.ipAddresses[0]
|
||||||
|
- $.environment.reporter.report($this, format('LBaaS is available at http://{0}:{1}{2}', $host, $lbaas.port, $lbaas.path))
|
||||||
|
- $.setAttr(deployed, true)
|
||||||
|
|
||||||
|
installLoadBalancer:
|
||||||
|
|
||||||
|
installLBaaS:
|
@ -0,0 +1,16 @@
|
|||||||
|
FormatVersion: 2.0.0
|
||||||
|
Version: 1.0.0
|
||||||
|
Name: Deploy HAProxy
|
||||||
|
|
||||||
|
Body: |
|
||||||
|
return HAProxyDeploy().stdout
|
||||||
|
|
||||||
|
Scripts:
|
||||||
|
HAProxyDeploy:
|
||||||
|
Type: Application
|
||||||
|
Version: 1.0.0
|
||||||
|
EntryPoint: deployHAProxy.sh
|
||||||
|
Files: []
|
||||||
|
Options:
|
||||||
|
captureStdout: true
|
||||||
|
captureStderr: true
|
@ -0,0 +1,19 @@
|
|||||||
|
FormatVersion: 2.0.0
|
||||||
|
Version: 1.0.0
|
||||||
|
Name: Deploy LBaaS
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
impl: $impl
|
||||||
|
|
||||||
|
Body: |
|
||||||
|
return LBaasDeploy('{0}'.format(args.impl)).stdout
|
||||||
|
|
||||||
|
Scripts:
|
||||||
|
LBaasDeploy:
|
||||||
|
Type: Application
|
||||||
|
Version: 1.0.0
|
||||||
|
EntryPoint: deployLBaaS.sh
|
||||||
|
Files: []
|
||||||
|
Options:
|
||||||
|
captureStdout: true
|
||||||
|
captureStderr: true
|
13
murano-apps/haproxy-based-lbaas/Resources/scripts/deployHAProxy.sh
Executable file
13
murano-apps/haproxy-based-lbaas/Resources/scripts/deployHAProxy.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
sudo add-apt-repository ppa:vbernat/haproxy-1.5 -y
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y haproxy
|
||||||
|
|
||||||
|
# Enabling HAProxy.
|
||||||
|
sudo sed -i 's/^ENABLED=.*/ENABLED=1/' /etc/default/haproxy
|
||||||
|
|
||||||
|
sudo chown -R $USER:$USER /etc/haproxy
|
||||||
|
|
||||||
|
# Starting HAProxy.
|
||||||
|
#sudo service haproxy restart
|
||||||
|
|
@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
impl=$1
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
|
||||||
|
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
|
||||||
|
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
|
||||||
|
|
||||||
|
sudo apt-get install -y python-dev python-pip git;
|
||||||
|
|
||||||
|
sudo apt-get install -y -q mysql-server libmysqlclient-dev
|
||||||
|
|
||||||
|
# Installing LBaaS API.
|
||||||
|
git clone https://github.com/nmakhotkin/lbaas_api.git
|
||||||
|
|
||||||
|
cd lbaas_api
|
||||||
|
|
||||||
|
sudo pip install .
|
||||||
|
sudo pip install mysql-python
|
||||||
|
|
||||||
|
# Configure LBaaS.
|
||||||
|
cp etc/lbaas.conf.sample etc/lbaas.conf
|
||||||
|
|
||||||
|
sudo chmod -R a+rw /var/log
|
||||||
|
|
||||||
|
# Configure lbaas logging.
|
||||||
|
sed -i 's/#verbose = false/verbose = true/g' etc/lbaas.conf
|
||||||
|
sed -i 's/#default_log_levels/default_log_levels/g' etc/lbaas.conf
|
||||||
|
sed -i 's/#log_file = <None>/log_file = \/var\/log\/lbaas.log/g' etc/lbaas.conf
|
||||||
|
|
||||||
|
# Configure lbaas impl.
|
||||||
|
sed -i "s/#impl = haproxy/impl = $impl/g" etc/lbaas.conf
|
||||||
|
|
||||||
|
# Configure database connection.
|
||||||
|
mysql --user=root --password=root -e "CREATE DATABASE lbaas;"
|
||||||
|
mysql --user=root --password=root -e "GRANT ALL ON lbaas.* TO 'root'@'localhost';"
|
||||||
|
|
||||||
|
sed -i 's/#connection = <None>/connection = mysql:\/\/root:root@localhost:3306\/lbaas/g' etc/lbaas.conf
|
||||||
|
sed -i 's/#max_overflow = <None>/max_overflow = -1/g' etc/lbaas.conf
|
||||||
|
sed -i 's/#max_pool_size = <None>/max_pool_size = 1000/g' etc/lbaas.conf
|
||||||
|
|
||||||
|
# Upgrade database.
|
||||||
|
lbaas-db-manage --config-file etc/lbaas.conf upgrade head
|
||||||
|
|
||||||
|
# Moving config to another place.
|
||||||
|
sudo mkdir /etc/lbaas
|
||||||
|
sudo chown -R $USER:$USER /etc/lbaas
|
||||||
|
sudo chown /var/log/lbaas.log
|
||||||
|
|
||||||
|
mv etc/lbaas.conf /etc/lbaas/lbaas.conf
|
||||||
|
|
||||||
|
cd ~
|
||||||
|
|
||||||
|
# Start lbaas.
|
||||||
|
lbaas-server --config-file /etc/lbaas/lbaas.conf >> lbaas.log 2>&1 &
|
98
murano-apps/haproxy-based-lbaas/UI/ui.yaml
Normal file
98
murano-apps/haproxy-based-lbaas/UI/ui.yaml
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
Version: 2
|
||||||
|
|
||||||
|
Application:
|
||||||
|
?:
|
||||||
|
type: io.murano.apps.lbaas.HAProxy
|
||||||
|
name: $.appConfiguration.name
|
||||||
|
implementation: $.appConfiguration.LBaasImpl
|
||||||
|
instance:
|
||||||
|
?:
|
||||||
|
type: io.murano.resources.LinuxMuranoInstance
|
||||||
|
name: generateHostname($.instanceConfiguration.unitNamingPattern, 1)
|
||||||
|
flavor: $.instanceConfiguration.flavor
|
||||||
|
image: $.instanceConfiguration.osImage
|
||||||
|
keyname: $.instanceConfiguration.keyPair
|
||||||
|
availabilityZone: $.instanceConfiguration.availabilityZone
|
||||||
|
assignFloatingIp: $.appConfiguration.assignFloatingIP
|
||||||
|
|
||||||
|
Forms:
|
||||||
|
- appConfiguration:
|
||||||
|
fields:
|
||||||
|
- name: name
|
||||||
|
type: string
|
||||||
|
label: Application Name
|
||||||
|
initial: 'HAProxy based LBaaS'
|
||||||
|
description: >-
|
||||||
|
Enter a desired name for the application. Just A-Z, a-z, 0-9, dash and
|
||||||
|
underline are allowed
|
||||||
|
- name: LBaasImpl
|
||||||
|
label: Load Balancer implementation.
|
||||||
|
type: string
|
||||||
|
description: >-
|
||||||
|
Specify Load balancer implementation for this current LBaaS. Only 'haproxy' is available now.
|
||||||
|
initial: haproxy
|
||||||
|
regexpValidator: '^haproxy$'
|
||||||
|
errorMessages:
|
||||||
|
invalid: Only 'haproxy' is available now.
|
||||||
|
required: true
|
||||||
|
- name: assignFloatingIP
|
||||||
|
type: boolean
|
||||||
|
label: Assign Floating IP
|
||||||
|
description: >-
|
||||||
|
Select to true to assign floating IP automatically
|
||||||
|
initial: false
|
||||||
|
required: false
|
||||||
|
widgetMedia:
|
||||||
|
css: {all: ['muranodashboard/css/checkbox.css']}
|
||||||
|
|
||||||
|
- instanceConfiguration:
|
||||||
|
fields:
|
||||||
|
- name: title
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
hidden: true
|
||||||
|
description: Specify some instance parameters on which the application would be created
|
||||||
|
- name: flavor
|
||||||
|
type: flavor
|
||||||
|
label: Instance flavor
|
||||||
|
description: >-
|
||||||
|
Select registered in Openstack flavor. Consider that application performance
|
||||||
|
depends on this parameter.
|
||||||
|
required: false
|
||||||
|
- name: osImage
|
||||||
|
type: image
|
||||||
|
imageType: linux
|
||||||
|
label: Instance image
|
||||||
|
description: >-
|
||||||
|
Select valid image for the application. Image should already be prepared and
|
||||||
|
registered in glance.
|
||||||
|
- name: keyPair
|
||||||
|
type: keypair
|
||||||
|
label: Key Pair
|
||||||
|
description: >-
|
||||||
|
Select the Key Pair to control access to instances. You can login to
|
||||||
|
instances using this KeyPair after the deployment of application.
|
||||||
|
required: false
|
||||||
|
- name: availabilityZone
|
||||||
|
type: azone
|
||||||
|
label: Availability zone
|
||||||
|
description: Select availability zone where application would be installed.
|
||||||
|
required: false
|
||||||
|
- name: network
|
||||||
|
type: network
|
||||||
|
label: Network
|
||||||
|
description: Select a network to join. 'Auto' corresponds to a default environment's network.
|
||||||
|
required: false
|
||||||
|
murano_networks: translate
|
||||||
|
- name: unitNamingPattern
|
||||||
|
type: string
|
||||||
|
label: Instance Naming Pattern
|
||||||
|
required: false
|
||||||
|
maxLength: 64
|
||||||
|
regexpValidator: '^[a-zA-z][-_\w]*$'
|
||||||
|
errorMessages:
|
||||||
|
invalid: Just letters, numbers, underscores and hyphens are allowed.
|
||||||
|
helpText: Just letters, numbers, underscores and hyphens are allowed.
|
||||||
|
description: >-
|
||||||
|
Specify a string, that will be used in instance hostname.
|
||||||
|
Just A-Z, a-z, 0-9, dash and underline are allowed.
|
BIN
murano-apps/haproxy-based-lbaas/logo.png
Normal file
BIN
murano-apps/haproxy-based-lbaas/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
25
murano-apps/haproxy-based-lbaas/manifest.yaml
Normal file
25
murano-apps/haproxy-based-lbaas/manifest.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
Format: 1.0
|
||||||
|
Type: Application
|
||||||
|
FullName: io.murano.apps.lbaas.HAProxy
|
||||||
|
Name: HAProxy based LBaaS
|
||||||
|
Description: |
|
||||||
|
HAProxy is a free, very fast and reliable solution offering high
|
||||||
|
availability, load balancing, and proxying for TCP and HTTP-based
|
||||||
|
applications.
|
||||||
|
Author: 'Mirantis, Inc'
|
||||||
|
Tags: [HTTP, TCP, Load Balancing as a Service, HAProxy]
|
||||||
|
Classes:
|
||||||
|
io.murano.apps.lbaas.HAProxy: HAProxy.yaml
|
||||||
|
io.murano.apps.lbaas.LoadBalancer: LoadBalancer.yaml
|
Loading…
x
Reference in New Issue
Block a user