This project uses Terraform and Docker to create a cluster of web servers and a load balancer for round-robin load balancing. The web servers serve a static page that displays a message "Hello from web-server (1..X)". The project also includes a health endpoint on both the web servers and load balancer that returns the name of the component. The project supports setting different versions for the web servers and load balancer.
- Download and run the script
fullauto.sh
by running the commandcurl https://raw.githubusercontent.com/wondersalmon/terraform-webcluster/main/scripts/fullauto.sh >> fullauto.sh && chmod +x fullauto.sh && ./fullauto.sh
in the terminal. - The script will check if Terraform is installed, and if not, it will install it based on your package manager.
- The script will then download the project, go to the project folder, initialize Terraform, and display a menu for working with the project.
Then the script will download the project, go to the folder with the project and initialize the terraform, and displays the menu for working with the project.
- Run the script
manager.sh
by running the commandcurl https://raw.githubusercontent.com/wondersalmon/terraform-webcluster/main/scripts/manage.sh >> manage.sh && chmod +x manage.sh && ./manage.sh
in the terminal. - The script will download the project, initialize Terraform, and display a menu for working with the project.
- Clone the repository by running the command
git clone https://github.com/wondersalmon/terraform-webcluster.git
in the terminal. - Navigate to the project folder
cd terraform-webcluster/terraform
- Initialize Terraform by running the command
terraform init
The cluster can be managed using the following Terraform commands:
- To launch the cluster, run the command
terraform apply
. - To launch the cluster with custom parameters, run the command
terraform apply -var "webservers_count=$webservers_count" -var "webserver_version=$webserver_version" -var "loadbalancer_version=$loadbalancer_version"
(specify custom parameters instead of variable values). - To delete the cluster, run the command
terraform destroy
. - To check the status of the cluster, run the command
curl -s localhost:8080/health
.
In addition to manual management, the project includes a Cluster Manager that allows you to start, stop, and check the status of the cluster. The Cluster Manager can be accessed by running the script manager.sh
after the project has been installed.
Note: fullauto.sh
script will install Terraform, download the project and run manager.sh
script.
This project provides a convenient and straightforward way to set up a cluster of web servers and a load balancer using Terraform and Docker. The project also includes a health endpoint and support for different versions of the web servers and load balancer. The Cluster Manager also makes it easy to start, stop, and check the status of cluster.