terraform-iaas-api-basic-ha.../README.md
Mauritz Uphoff fa94df6ae5
Some checks are pending
CI / Terraform Format & Validate (push) Waiting to run
CI / TruffleHog Secrets Scan (push) Successful in 12s
fmt code
2025-06-17 11:30:56 +02:00

54 lines
No EOL
2 KiB
Markdown

# Basic High Availability (HA) Setup Using VRRP
This guide provides a comprehensive, step-by-step process for setting up a Basic High Availability (HA) cluster using the Virtual Router Redundancy Protocol (VRRP) with the STACKIT CLI. In this HA configuration, one virtual machine (VM) functions as the active primary node while the secondary remains on standby, ready to take over in the event of a failure.
> For setup instructions using the STACKIT CLI instead of Terraform, please refer to the [STACKIT CLI Guide](STACKIT-CLI-GUIDE.md).
## Overview of Core Components
- **Active/Passive VM Configuration**: Ensures redundancy, with one active node and a standby failover node.
- **VRRP Synchronization**: Maintains state information between nodes, enabling seamless failover.
- **Security Group Rules**: Configured to allow VRRP and ICMP traffic.
- **Virtual IP (vIP)**: A dedicated internal IP address bound to a shared network interface card (NIC) port for seamless failover.
- **Public IP Binding**: Enables external access to the HA endpoint.
### Diagrams
- **HA Traffic Flow**:
![HA Traffic Flow Diagram](docs/ha.svg)
- **vIP Binding Concept**:
![vIP Binding Diagram](docs/vip.svg)
## Testing the Setup
After completing the setup, use the [test-setup.sh](test-setup.sh) script to verify that the Apache server is operational on each machine. Executing this script should yield the following results:
```bash
Performing curl on IP: 193.148.177.243
<center><h1>example01</h1>
Performing curl on IP: 193.148.161.92
<center><h1>example02</h1>
Performing curl on IP: 193.148.169.230
<center><h1>example01</h1>
```
The output indicates a successfully functional VRRP setup.
### Failover Testing
To test failover, stop the master VM and perform another `curl` request to the vIP WAN IP:
```bash
vip01_wan_ip=$(terraform output -raw vip01-wan-ip)
curl $vip01_wan_ip
<center><h1>example02</h1>
```
The response confirms that the failover from the master to the backup has occurred
successfully, demonstrating the effectiveness of the HA setup.