-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple 2 nodes setup (1DB with HA enabled) (#111)
* Added default key to rts deployments * Added default key to rts deployments * Removed hcl spurious lock file * Removed hcl spurious lock file * Added simple 2 nodes setup (1DB with HA enabled) * Updated base image from redis 7.1 to 7.4.0
- Loading branch information
1 parent
34ddf4a
commit cc5fed2
Showing
9 changed files
with
330 additions
and
56 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/common.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
################################################################################ | ||
# This is the bucket holding this specific setup tfstate | ||
################################################################################ | ||
terraform { | ||
backend "s3" { | ||
bucket = "performance-cto-group" | ||
region = "us-east-1" | ||
key = "testing-infrastructure/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge.tfstate" | ||
} | ||
} | ||
|
76 changes: 76 additions & 0 deletions
76
terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/db-resources.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
resource "aws_instance" "server" { | ||
count = var.server_instance_count | ||
ami = var.instance_ami | ||
instance_type = var.server_instance_type | ||
subnet_id = data.terraform_remote_state.shared_resources.outputs.subnet_public_id | ||
vpc_security_group_ids = ["${data.terraform_remote_state.shared_resources.outputs.performance_cto_sg_id}"] | ||
key_name = var.key_name | ||
|
||
root_block_device { | ||
volume_size = var.instance_volume_size | ||
volume_type = var.instance_volume_type | ||
iops = var.instance_volume_iops | ||
encrypted = var.instance_volume_encrypted | ||
delete_on_termination = true | ||
} | ||
|
||
volume_tags = { | ||
Environment = "${var.environment}" | ||
Project = "${var.environment}" | ||
Name = "ebs_block_device-${var.setup_name}-DB-${count.index + 1}" | ||
setup = "${var.setup_name}" | ||
triggering_env = "${var.triggering_env}" | ||
github_actor = "${var.github_actor}" | ||
github_org = "${var.github_org}" | ||
github_repo = "${var.github_repo}" | ||
github_sha = "${var.github_sha}" | ||
} | ||
|
||
tags = { | ||
Environment = "${var.environment}" | ||
Project = "${var.environment}" | ||
Name = "${var.setup_name}-DB-${count.index + 1}" | ||
setup = "${var.setup_name}" | ||
triggering_env = "${var.triggering_env}" | ||
github_actor = "${var.github_actor}" | ||
github_org = "${var.github_org}" | ||
github_repo = "${var.github_repo}" | ||
github_sha = "${var.github_sha}" | ||
} | ||
|
||
################################################################################ | ||
# This will ensure we wait here until the instance is ready to receive the ssh connection | ||
################################################################################ | ||
provisioner "remote-exec" { | ||
script = "./../scripts/wait_for_instance.sh" | ||
connection { | ||
host = self.public_ip # The `self` variable is like `this` in many programming languages | ||
type = "ssh" # in this case, `self` is the resource (the server). | ||
user = var.ssh_user | ||
private_key = file(var.private_key) | ||
#need to increase timeout to larger then 5m for metal instances | ||
timeout = "5m" | ||
agent = "false" | ||
} | ||
} | ||
################################################################################ | ||
# Deployment related | ||
################################################################################ | ||
|
||
################################################################################ | ||
# Install RE | ||
################################################################################ | ||
provisioner "remote-exec" { | ||
script = "./install-re-7.4.sh" | ||
connection { | ||
host = self.public_ip # The `self` variable is like `this` in many programming languages | ||
type = "ssh" # in this case, `self` is the resource (the server). | ||
user = var.ssh_user | ||
private_key = file(var.private_key) | ||
#need to increase timeout to larger then 5m for metal instances | ||
timeout = "10m" | ||
agent = "false" | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/install-re-7.4.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# exit the script if any command fails. | ||
set -e | ||
|
||
V=7.4.2 | ||
FULL=$V-216 | ||
FILENAME=/tmp/re.tar | ||
OS="focal" | ||
|
||
wget -O $FILENAME https://s3.amazonaws.com/redis-enterprise-software-downloads/${V}/redislabs-${FULL}-${OS}-amd64.tar | ||
|
||
cd /tmp | ||
tar vxf /tmp/re.tar | ||
echo "DNSStubListener=no" | sudo tee -a /etc/systemd/resolved.conf | ||
sudo mv /etc/resolv.conf /etc/resolv.conf.orig | ||
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf | ||
sudo service systemd-resolved restart | ||
sudo /tmp/install.sh -y | ||
|
||
# Cleanup | ||
rm -f $FILENAME |
15 changes: 15 additions & 0 deletions
15
terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/output.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
output "server_public_ip" { | ||
value = aws_instance.server[*].public_ip | ||
} | ||
|
||
output "server_private_ip" { | ||
value = aws_instance.server[*].private_ip | ||
} | ||
|
||
output "server_instance_type" { | ||
value = var.server_instance_type | ||
} | ||
|
||
output "setup_name" { | ||
value = var.setup_name | ||
} |
25 changes: 25 additions & 0 deletions
25
terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/prepare_ips.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import subprocess | ||
import json | ||
|
||
# Run the "terraform output json" command | ||
output = subprocess.run(["terraform", "output", "-json"], stdout=subprocess.PIPE) | ||
|
||
output_json = json.loads(output.stdout.decode()) | ||
total_nodes = len(output_json["server_private_ip"]["value"]) | ||
|
||
print("#!/bin/bash\n") | ||
print("TOTAL_NODES={}\n".format(total_nodes)) | ||
suffix_len = len("perf-cto-RE-") | ||
setup_name = output_json["setup_name"]["value"].replace(".", "_").replace("-", "_") | ||
setup_name = setup_name[suffix_len:] | ||
server_instance_type = output_json["server_instance_type"]["value"].replace(".", "_") | ||
|
||
print('CLUSTER_NAME="{}"\n'.format(setup_name)) | ||
print("\n#internal IP addresses") | ||
cleaned_json = {} | ||
for keyn, v in enumerate(output_json["server_private_ip"]["value"], start=1): | ||
print("B_M{}_I={}".format(keyn, v)) | ||
|
||
print("\n#external IP addresses") | ||
for keyn, v in enumerate(output_json["server_public_ip"]["value"], start=1): | ||
print("B_M{}_E={}".format(keyn, v)) |
17 changes: 17 additions & 0 deletions
17
terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/shared_resources.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# provider | ||
provider "aws" { | ||
region = var.region | ||
} | ||
|
||
################################################################################ | ||
# This is the shared resources bucket key -- you will need it across environments like security rules,etc... | ||
# !! do not change this !! | ||
################################################################################ | ||
data "terraform_remote_state" "shared_resources" { | ||
backend = "s3" | ||
config = { | ||
bucket = "performance-cto-group" | ||
key = "benchmarks/infrastructure/shared_resources.tfstate" | ||
region = "us-east-1" | ||
} | ||
} |
Oops, something went wrong.