This image can interact with EC2 and AutoScaling from AWS and update HAProxy configuration
1.8K
This image can interact with EC2 and AutoScaling from AWS and update HAProxy configuration
This Load Balancer will be running as a part of AWS Cloudformation to launch an EC2 instance. This AutoScaling Handler(Docker Image) will constantly request a list of active IP Address from AWS.
The IP Addresses will be used to create a temporary configuration file, which will be monitored by a bash script inside of the EC2 Instance comparing with the HAPRoxy configuration file.
If there is any diff between the temporary file and the HAProxy configuration file, the HAProxy configuration will be overwritten by the temporary file and the bash script will gracefully reload the proxy service.
The CloudFormation template is given for your reference.
The CloudFormation will download and install up to docker-compose.
All you need to do is, upload refresher.sh and deploy.sh into your S3 bucket and add following command inside of UserData in the template.
[Local|Instance]$ aws s3 sync your-bucket-with-bash-files your-destination
[Local|Instance]$ chmod -R +x /home/ec2-user/deploy.sh
[Local|Instance]$ sudo -E /home/ec2-user/deploy.sh
The Auto Scaling Handler is implemented by NodeJS and it can be run by
[Local|Instance]$ npm start
However, the script with compulsory modules are all built inside of docker image, so simply
[Local|Instance]$ docker pull vovxox/lb
And fill name of your AutoScaling group inside of docker-compose as an environment variable
Lastly, run the docker image by
[Local|Instance]$ docker-compose up as
The refresh script is designed to monitor the HAProxy configuration file and the temporary configuration file generated by the Auto Scaling Handler and replace the original configuration file with the temporary file.
Content type
Image
Digest
Size
263.2 MB
Last updated
over 9 years ago
docker pull vovxox/lb