These scripts were coded to load test various infrastructure configurations.
For example Nginx as a Loadbalancer, or Basho-Riak as a database server.
The application servers run Python-Django.
cookbooks are written as wrappers around the underlying cookbooks from Supermarket.
In case you use ELB as a loadbalancer and a fixed number of database servers these scripts are of little help.
Or as a picture, if your stack looks like this:
ELB
|
-------------------------------------
| | | |
AppServer AppServer AppServer AppServer
| | | |
-------------------------------------
|
Database Server
- elastic scaling – add and remove any instance in any layer without the need of manual changes in configuration files and re-deploy of those files
- run “commands”
- restart all instances in a layer
- drop all data and re-create the databases with fixtures
- deploy Gatling for Stress- and Loadtest – for example Gatling uses the configured Loadbalancer
- rolling deploy – zero downtime when deploying a new version of the application
- seamless transition during add/remove of any instances – for example an app server instance is shutdown before the loadbalancer removed the instance from its inventory
-
Opsworks has the concept of life cycle events which trigger custom Chef recipes.
-
Information about the layers and instances is provided at runtime by Opsworks.
layers = node[:cloud][:layers]
this_instance = node[:cloud][:instance]
this_node = node[:cloud][:this_node]
my_layer = node[:cloud][:my_layer]
- Deployment of an appliction generates the
deploy
life cycle event and the name of the application is available at runtime
applications = node[:deploy]
applications.each do |app_name, deploy_info|
...
end
Whenever a life cycle event occurs on a layer a custom recipe is called on each instance of the layer.
The custom recipe reads the information of the current instances in all layers and for example uses this information to re-write a configuration file, to deploy the file and to restart an application server.
To add a new “command” a new application is setup in Opsworks and code is added to run the appropriate custom recipe for deploy
.
configuration of the recipes is done using custom json in the Stack Settings and attributes of the cookbooks.
in the ri_base attributes
change default.rb
- <your-domain>
- <your-s3-folder>
change services.rb
clone the cookbooks from opsworks-cookbooks
git clone git@github.com:aws/opsworks-cookbooks.git
create the vagrant box for Chef Solo provisions
vagrant up
edit the Vagrantfile to either run a defined runlist from runlist.rb or a single custom recipe.
start the provision with
vagrant provision
Configure the layers such that the appropriate custom recipes are called for all of the life cycle events.
Leave a Reply